Files
parallel-hashmap/examples/hash_std.h
T

34 lines
793 B
C++
Raw Normal View History

2019-03-30 14:10:57 -04:00
#ifndef phmap_example_hash_std_
#define phmap_example_hash_std_
2019-03-31 11:59:32 -04:00
#include <parallel_hashmap/phmap_utils.h> // minimal header providing phmap::HashState()
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
{
2019-03-31 10:59:35 -04:00
return _first == o._first && _last == o._last && _age == o._age;
2019-03-30 14:10:57 -04:00
}
string _first;
string _last;
2019-03-31 10:59:35 -04:00
int _age;
2019-03-30 14:10:57 -04:00
};
namespace std
{
2019-03-31 10:59:35 -04:00
// inject specialization of std::hash for Person into namespace std
// ----------------------------------------------------------------
template<> struct hash<Person>
2019-03-30 14:10:57 -04:00
{
std::size_t operator()(Person const &p) const
{
2019-03-31 10:59:35 -04:00
return phmap::HashState().combine(0, p._first, p._last, p._age);
2019-03-30 14:10:57 -04:00
}
};
}
#endif // phmap_example_hash_std_