I want to have a map that has a homogeneous key type but heterogeneous data types.
I want to be able to do something like (pseudo-code):
boost::map<std::string, magic_goes_here> m;
m.add<int>("a", 2);
m.add<std::string>("b", "black sheep");
int i = m.get<int>("a");
int j = m.get<int>("b"); // error!
I could have a pointer to a base class as the data type but would rather not.
I've never used boost before but have looked at the fusion library but can't figure out what I need to do.
Thanks for your help.
See Question&Answers more detail:os