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
Post a Comment