How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
Thank you, Andrew that's good to know, I have spotted both types but couldn't get it to compile std::any or std::variant. Might have to look into CPP supported versions for emscripten.
I had some business with Arduino recently, so I wrote my implementation of Variant without typeinfo: Pastebin (there is unused get_type struct, don't get confused with it)
Compiles and works with g++ -std=c++11 and g++ -std=c++17
If you can include typeinfo, it's not so hard to implement class like Any by yourself
If you're familiar with C++ variadic templates (who knows), you can make Variant by yourself
If you don't manage to include standart Any or Variant, and you need sum type with fixed number of hidden (I don't know how to call them) types you can make template Variant class (it will be pretty ugly, but it'll work, hehe)
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
Thank you so much for thinking to come back here and post that. My project has come a long way now. I had some help from the maintainers of sol. A Lua CPP helper library. But I really should look into polymorphism. Currently I haven't even used CPP classes. Everything is in functions for better or worse.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you, Andrew that's good to know, I have spotted both types but couldn't get it to compile std::any or std::variant. Might have to look into CPP supported versions for emscripten.
I had some business with Arduino recently, so I wrote my implementation of Variant without
typeinfo
: Pastebin (there is unusedget_type
struct, don't get confused with it)Compiles and works with
g++ -std=c++11
andg++ -std=c++17
If you can include typeinfo, it's not so hard to implement class like Any by yourself
If you're familiar with C++ variadic templates (who knows), you can make Variant by yourself
If you don't manage to include standart Any or Variant, and you need sum type with fixed number of hidden (I don't know how to call them) types you can make template Variant class (it will be pretty ugly, but it'll work, hehe)
Thank you so much for thinking to come back here and post that. My project has come a long way now. I had some help from the maintainers of sol. A Lua CPP helper library. But I really should look into polymorphism. Currently I haven't even used CPP classes. Everything is in functions for better or worse.