c++ - Registry of different types of data -


i want keep kind of container type maps 1 value of type. want std::map<std::typeindex, t> t depends on type index with. std::map doesn't nice way of doing because types rigid. simplest solution can use doing this?

if map type-erased container boost::any, can @ least recover type if know is:

std::map<std::typeindex, boost::any> m;  m[typeid(foo)] = foo(1, true, 'x');  foo & x = boost::any_cast<foo&>(m[typeid(foo)]); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -