From 657daee52af7805c509992bacc4d48ab30f5bee7 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 12 May 2019 10:40:32 -0400 Subject: [PATCH] update comments --- examples/hash_std.h | 3 ++- examples/hash_value.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) 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);