diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-13 14:34:24 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-13 14:34:24 +0200 |
commit | ca41ca8f9a6b21588248e5fee1a013363f3f52a8 (patch) | |
tree | 6e791ddac1c6f794273a9701c0c7f1bc9ec3d000 /build/key-set | |
parent | 0cee33621a93d3348a1bf19a0c94441b717cbcbc (diff) |
Add support for "first" and "last" execution modes
Diffstat (limited to 'build/key-set')
-rw-r--r-- | build/key-set | 18 |
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 |