I wanna stringify object in a template class, and I wrote this:
template <typename K, typename V>
template <typename T>
auto HashTable<K, V>::Stringify(T key) -> std::string{
if(std::is_same<T, std::string>::value){...}
else if(std::is_same<T, Bar*>::value){...}
else{...}
}
when compiling, it say: "
In instantiation of ‘std::string HashTable<K, V>::Stringify(T) [with T
= Bar*; K = int; V = Bar*; std::string =
std::__cxx11::basic_string<char>]’: invalid operands of types ‘const
char [8]’ and ‘Bar* const’ to binary ‘operator+’"
according to the error pointing to line number of first if-statement, it seems that the instantiation matches the first if-statement
why is that? Is there some error in my code and how should I correct it? or is there another approach to my goal? thanks!