Skip to content

Instantly share code, notes, and snippets.

@wackoisgod
Created September 7, 2019 02:17
Show Gist options
  • Save wackoisgod/715ef0437b0c315eef962d8e742779b3 to your computer and use it in GitHub Desktop.
Save wackoisgod/715ef0437b0c315eef962d8e742779b3 to your computer and use it in GitHub Desktop.
#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