I have two std:map where one's key is of type CustomClass1 and another's key is of type CustomClass2, but their value's type is the same, std::string.
//first map
std::map<CustomClass1, std::string>
//second map
std::map<CustomClass2, std::string>
I want to create a template function that takes a key as input that can either be CustomClass1 or CustomClass2, and tries to find the associated string in the map.
I know how to find a value given a key in a map:
map<key, std::string>::iterator iterator = map.find(key);
if(iterator1 != map.end()){
//value found
}
How can I create such a method with a template function?