Wednesday, May 30, 2007

Making std::pair work as the key of hash_map in VC

Simple hack:
namespace stdext
{
  template<typename T1, typename T2> inline size_t hash_value(const std::pair<T1, T2>& _Keyval)
  {
    return hash_value(_Keyval.first) * 196613 + hash_value(_Keyval.second);
  }
}

No comments: