diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-13 14:39:46 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-13 14:39:46 +0200 |
commit | 75d03492c0a42031a987969a6eb20dd2121f54d1 (patch) | |
tree | 967f3fd866c28c9e03c96b02dddf067da38f1a90 /build/key-set | |
parent | ca41ca8f9a6b21588248e5fee1a013363f3f52a8 (diff) |
Rename set_key to map_key; feels more correct
Diffstat (limited to 'build/key-set')
-rw-r--r-- | build/key-set | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/build/key-set b/build/key-set deleted file mode 100644 index 1d0b532..0000000 --- a/build/key-set +++ /dev/null @@ -1,59 +0,0 @@ -// file : build/key-set -*- C++ -*- -// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC -// license : MIT; see accompanying LICENSE file - -#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 - // post for deatils. - // - - template <typename T> - struct set_key - { - mutable const T* p; - - 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> - struct map_iterator_adapter: I - { - typedef const typename I::value_type::second_type value_type; - typedef value_type* pointer; - typedef value_type& reference; - - map_iterator_adapter () {} - map_iterator_adapter (I i): I (i) {} - - map_iterator_adapter& - operator= (I i) {static_cast<I&> (*this) = i; return *this;} - - reference operator* () const {return I::operator* ().second;} - pointer operator-> () const {return &I::operator-> ()->second;} - }; -} - -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 |