Created
September 7, 2019 02:17
-
-
Save wackoisgod/715ef0437b0c315eef962d8e742779b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <variant> | |
#include <functional> | |
struct Foo | |
{ | |
int handle = {}; | |
}; | |
struct Bar | |
{ | |
int x; | |
int y; | |
}; | |
class Food | |
{ | |
public: | |
Food(); | |
}; | |
struct Meow | |
{ | |
Food* food; | |
Bar thing; | |
}; | |
static std::vector<std::variant<Foo, Bar, Meow>> thing; | |
Food::Food() | |
{ | |
thing.push_back(Foo()); | |
} | |
int main() | |
{ | |
thing.push_back(Foo()); | |
thing.push_back(Bar()); | |
thing.push_back(Meow()); | |
Meow& x = std::get<Meow>(thing[2]); | |
x.food = new Food(); | |
x.thing = Bar(); | |
x.thing.x = 1; | |
Food* kitty = std::get<Meow>(thing[2]).food; | |
std::cout << "Hello World!\n"; | |
std::cout << static_cast<void*>(kitty); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment