Why does the compiler expect a separate specialization of the template on (concrete) types Tand const T? Let me set an example. I had an unordered map with a type keyKey
std::unordered_map<Key, Value> data;
and to compile it, I had to specialize std::hashin type Keyas
namespace std {
template<>
class hash<Key> { };
}
However, when I changed the map type to
std::unordered_map<const Key, Value> data;
the compiler did not use my specialization and instead chose a generic one std::hash<T>, which is slightly larger than the compile time statement until I specialize std::hash<const Key>.
Discarding a utility that determines the type of card key with const, why const Tdoesn't it collapse before Twhen looking for specialization in this case?
, std::hash (), ?