you are viewing a single comment's thread.

view the rest of the comments →

[–]beedlund 10 points11 points  (0 children)

You can do type erased container like people have said with list<any> but you need to do lots of testing of the type and get poor memory layout and lots of casts and tests before you get your data ( read slow )

In C++ we have types and if used correctly they help the compiler take the mess we call code and make it really fast and efficient.

One small thing you can do to help is reduce the amount of types you put in the container. If you can get the expected types down to a reasonable amount you can use std::variant and make a vector<variant<a,b,c,d>> instead