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

标签 c++ c++11 std standard-library

我的问题很快。

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

最佳答案

不,它没有。 [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*>;

而且,这样的事情到底意味着什么?

关于c++ - c++ 是否为引用指定了哈希函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32380081/

相关文章:

c++ - 用什么代替 std::map::emplace?

c++ - 有没有办法通过数组类型专门化函数模板?

c++ - 枚举比较运算符的重新定义

c++ - 在什么情况下我必须使用 std::function?

c++ - 行号 0 超出范围 0..-1 LIBPQ

c++ - "POR"在嵌入式开发中是什么意思?

c++ - C++ 循环中的作用域

c++ - 链接器错误。这不可能

c++ - 为什么 std::cout 而不是简单的 cout?

c++ - 如何解决 C++ 中的这个运行时错误? - "Stack around variable was corrupted"