update comments

This commit is contained in:
greg
2019-05-12 10:40:32 -04:00
parent 113be533fb
commit 657daee52a
2 changed files with 5 additions and 1 deletions
+2 -1
View File
@@ -20,7 +20,8 @@ struct Person
namespace std namespace std
{ {
// inject specialization of std::hash for Person into 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<Person> template<> struct hash<Person>
{ {
std::size_t operator()(Person const &p) const std::size_t operator()(Person const &p) const
+3
View File
@@ -12,6 +12,9 @@ struct Person
return _first == o._first && _last == o._last && _age == o._age; 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<Person> specialization
// --------------------------------------------------------------------------------------
friend size_t hash_value(const Person &p) friend size_t hash_value(const Person &p)
{ {
return phmap::HashState().combine(0, p._first, p._last, p._age); return phmap::HashState().combine(0, p._first, p._last, p._age);