hash_map with unsigned long long keys

Martin Beaudoin beaudoin.martin@ireq.ca
Wed Oct 1 14:20:00 GMT 2003


Hello,

I need to use a hash_map with unsigned long long keys.

Currently, this type of key is not supported by libstdc++.

I would like to propose the following addition to the file
gcc/libstdc++-v3/include/ext/hash_fun.h:


---------------------------------------------------------------------------------

template<> struct hash<long long> {
   size_t operator()(long long __x) const { return __x; }
};
template<> struct hash<const long long> {
   size_t operator()(const long long __x) const { return __x; }
};

template<> struct hash<unsigned long long> {
   size_t operator()(unsigned long long __x) const { return __x; }
};
template<> struct hash<const unsigned long long> {
   size_t operator()(const unsigned long long __x) const { return __x; }
};

----------------------------------------------------------------------------------


This simple addition on my local development system gave me the expected 
  functionnality currently missing with g++ hash_maps.

Thank you.

--
Martin Beaudoin



More information about the Libstdc++ mailing list