摘自MSDN,以VS2012版为主 1、hash类模板 定义如下: [cpp] view plain copy template<class Ty> struct hash : public unary_function<Ty, size_t> { size_t operator()(Ty _Val) const; }; 并给出一个例子: [cpp] view plain copy // std_tr1__functional__hash.cpp // compile with: /EHsc #include <functional> #include <iostream> #include <unordered_set> int main() { std::unordered_set<int, std::hash<int> > c0; c0.insert(3); std::cout << *c0.find(3) << std::endl; return (0); } 输出结果3 2.unordered_set类模板 定义: [cpp] view plain copy template<class Key, class Hash = std::hash<Key>, class Pred = std::equal_to<Key>, class Alloc = std::allocator<Key> > class unordered_set;