diff --git a/examples/hash_std.h b/examples/hash_std.h index 1284bd2..debf4a9 100644 --- a/examples/hash_std.h +++ b/examples/hash_std.h @@ -20,7 +20,8 @@ struct Person namespace std { // inject specialization of std::hash for Person into namespace std - // ---------------------------------------------------------------- + // An alternative is to provide a hash_value() friend function (see hash_value.h) + // ------------------------------------------------------------------------------ template<> struct hash { std::size_t operator()(Person const &p) const diff --git a/examples/hash_value.h b/examples/hash_value.h index 81d8574..ffcc3e0 100644 --- a/examples/hash_value.h +++ b/examples/hash_value.h @@ -12,6 +12,9 @@ struct Person return _first == o._first && _last == o._last && _age == o._age; } + // Demonstrates how to provide the hash function as a friend member function of the class + // This can be used as an alternative to providing a std::hash specialization + // -------------------------------------------------------------------------------------- friend size_t hash_value(const Person &p) { return phmap::HashState().combine(0, p._first, p._last, p._age);