Files
parallel-hashmap/examples/hash_std.h
T

38 lines
787 B
C++
Raw Normal View History

2019-03-30 14:10:57 -04:00
#ifndef phmap_example_hash_std_
#define phmap_example_hash_std_
#include <parallel_hashmap/phmap_utils.h>
2019-03-30 20:50:47 -04:00
#include <string>
2019-03-30 14:10:57 -04:00
using std::string;
struct Person
{
bool operator==(const Person &o) const
{
return _first == o._first && _last == o._last;
}
string _first;
string _last;
};
namespace std
{
// inject specialization of std::hash for Person into namespace std
// ----------------------------------------------------------------
template<>
struct hash<Person>
{
std::size_t operator()(Person const &p) const
{
std::size_t seed = 0;
phmap::hash_combine(seed, p._first);
phmap::hash_combine(seed, p._last);
return seed;
}
};
}
#endif // phmap_example_hash_std_