Store multiple types in a single std::map in C++ with std::any, just like a python dict

1 · RvE · Sept. 23, 2020, midnight
In C++, everything has a type. When declaring a function you specify the return type and for each parameter you specify what type it is, just as for regular variables. Templates aside (those still have a type), you almost always know what type of data you're working with. There is the 'auto' keyword, which can save you a lot of typing and duplicate code, but fundamentally you're still working with types. Since C++ 17 you can use 'std::any' to store anything, without knowing the type. This is awe...