DEV Community

Discussion on: C++ how do I store any value in a map

Collapse
 
aka_dude profile image
Andrew Andersen • Edited

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)

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

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.