C++ 什么';s差异-struct std::hash<;T>;vs名称空间std{struct hash<;T>;}?
这两种std::hash专门化变体之间有什么区别吗C++ 什么';s差异-struct std::hash<;T>;vs名称空间std{struct hash<;T>;}?,c++,C++,这两种std::hash专门化变体之间有什么区别吗 template <> struct std::hash<T> { size_t operator()(const T& x) const { return ...; } }; 模板 struct std::hash{ 大小\u t运算符()(常数t&x)常数{ 返回。。。; } }; 名称空间std{ 模板 结构散列{ 大小\u t运算符()(常数t&x)常数{ 返回。。。; } }; }/
template <>
struct std::hash<T> {
size_t operator()(const T& x) const {
return ...;
}
};
模板
struct std::hash{
大小\u t运算符()(常数t&x)常数{
返回。。。;
}
};
名称空间std{
模板
结构散列{
大小\u t运算符()(常数t&x)常数{
返回。。。;
}
};
}//std结束
这个:
template <>
struct std::hash<T> {
size_t operator()(const T& x) const {
return ...;
}
};
namespace std {
template <>
struct hash<T> {
size_t operator()(const T& x) const {
return ...;
}
};
} // end of std
模板
struct std::hash{
大小\u t运算符()(常数t&x)常数{
返回。。。;
}
};
这是不标准的。它是编译器提供的扩展,不可移植
这个:
template <>
struct std::hash<T> {
size_t operator()(const T& x) const {
return ...;
}
};
namespace std {
template <>
struct hash<T> {
size_t operator()(const T& x) const {
return ...;
}
};
} // end of std
名称空间std{
模板
结构散列{
大小\u t运算符()(常数t&x)常数{
返回。。。;
}
};
}//std结束
这是标准C++