aboutsummaryrefslogtreecommitdiff
path: root/build/key-set
diff options
context:
space:
mode:
Diffstat (limited to 'build/key-set')
-rw-r--r--build/key-set18
1 files changed, 18 insertions, 0 deletions
diff --git a/build/key-set b/build/key-set
index 8c197b8..1d0b532 100644
--- a/build/key-set
+++ b/build/key-set
@@ -5,6 +5,9 @@
#ifndef BUILD_KEY_SET
#define BUILD_KEY_SET
+#include <utility> // declval()
+#include <functional> // hash
+
namespace build
{
// Google the "Emulating Boost.MultiIndex with Standard Containers" blog
@@ -18,6 +21,7 @@ namespace build
set_key (const T* v = 0): p (v) {}
bool operator< (const set_key& x) const {return *p < *x.p;}
+ bool operator== (const set_key& x) const {return *p == *x.p;}
};
template <typename I>
@@ -38,4 +42,18 @@ namespace build
};
}
+namespace std
+{
+ template <typename T>
+ struct hash<build::set_key<T>>: hash<T>
+ {
+ size_t
+ operator() (build::set_key<T> x) const
+ noexcept (noexcept (declval<hash<T>> () (*x.p)))
+ {
+ return hash<T>::operator() (*x.p);
+ }
+ };
+}
+
#endif // BUILD_KEY_SET