I wrote a function template about google::protobuf::Map,code as follows:
template <typename K, typename V>
struct ContainImpl<google::protobuf::Map<K, V>, K> {
static bool contains(const google::protobuf::Map<K, V>& container, const K& value) {
return container.find(value) != container.end();
}
};
template <typename Container, typename T>
bool Contains(const Container& container, const T& value) {
return ContainImpl<Container, T>::contains(container, value);
}
then,I call the function in this way:
Contains(*googleMapPtr, "operator_mykey1"); //googleMapPtr is ptr of google::protobuf::Map<string, string>
Finally, The compiler recognizes the call of Contains as
bool Contains(const Container&, const T&) [with Container = google::protobuf::Map<std::basic_string<char>, std::basic_string<char> >; T = char [16]]'
because of the diff between std::basic_string and char [16], it miss the template of ContainImpl.so why the C++ compiler recognize the "operator_mykey1" type as char[16], how can i deal with it. Sincerely looking forward to the answer。