c ++是否为引用指定了哈希函数?

The*_*rom 1 c++ std standard-library c++11

我的问题很快.

C++标准库是否为引用实现了哈希函数,例如 std::hash<T&>

Bar*_*rry 6

不,不是的.[function.objects]中列举的专业化是:

// 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*>;
Run Code Online (Sandbox Code Playgroud)

那么,这样的事情甚至意味着什么呢?