Theo Sandstrom
Theo Sandstrom

Reputation: 134

Does the c++ specify a hash function for references?

My question is a quick one.

Does the C++ standard library implement a hash function for references, like std::hash<T&>

Upvotes: 1

Views: 593

Answers (1)

Barry
Barry

Reputation: 303377

No, it does not. The specializations enumerated in [function.objects] are:

// Hash function specializations
template <> struct hash<bool>;
template <> struct hash<char>;
template <> struct hash<signed char>;
template <> struct hash<unsigned char>;
template <> struct hash<char16_t>;
template <> struct hash<char32_t>;
template <> struct hash<wchar_t>;
template <> struct hash<short>;
template <> struct hash<unsigned short>;
template <> struct hash<int>;
template <> struct hash<unsigned int>;
template <> struct hash<long>;
template <> struct hash<long long>;
template <> struct hash<unsigned long>;
template <> struct hash<unsigned long long>;

template <> struct hash<float>;
template <> struct hash<double>;
template <> struct hash<long double>;

template<class T> struct hash<T*>;

Furthermore, what would such a thing even mean?

Upvotes: 6

Related Questions