How can I implement a map with different data types as values?
I want to put two (not more) different data types as values into a map as shown in the following example: typeX A, B, ...; typeY Z, Y, ...; void func (typeX) { ... } void func (typeY) { ... } std::map <std::string, what_to_put_here??> map; map["a"] = A; map["z"] = Z; ... std::vector<std::string> list; // This list will be something like "a", "y", ... for (unsigned int i = 0; i < list.size(); ++i) func( map[list[i]] ) Obviously this doesn't work, as the map will only accept one data type of value. However, when looping over list , the call to func() should be unambiguous since the type of map