what hash function is being used by boost c++ unordered_map ? I meant what kind of hash algorithms being used by boost::hash, for examp开发者_运维百科le
template<> struct hash;
Thanks
By default, it uses boost::hash :)
It depends on the type you are using, if you look here the boost::hash
template class is specialised:
template<> struct hash<bool>;
template<> struct hash<char>;
template<> struct hash<signed char>;
template<> struct hash<unsigned char>;
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<unsigned long>;
template<> struct hash<long long>;
template<> struct hash<unsigned long long>;
template<> struct hash<float>;
template<> struct hash<double>;
template<> struct hash<long double>;
template<> struct hash<std::string>;
template<> struct hash<std::wstring>;
template<typename T> struct hash<T*>;
You can also specify your own hash as the third template argument:
namespace boost {
template<typename Key, typename Mapped, typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key>,
typename Alloc = std::allocator<std::pair<Key const, Mapped> > >
class unordered_map;
精彩评论