aboutsummaryrefslogtreecommitdiff
path: root/build/map-key
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-18 12:32:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-18 12:32:55 +0200
commit28c82c861e38fe05a25e916563e0551ed8fce91e (patch)
tree0db8852340a2aa98053b237917e2dce1c4343f56 /build/map-key
parent4cda4b89c16932f02e04c5019a71b659ccf821e6 (diff)
Move map-key from build2 to libbutl, rename multi-index
Diffstat (limited to 'build/map-key')
-rw-r--r--build/map-key59
1 files changed, 0 insertions, 59 deletions
diff --git a/build/map-key b/build/map-key
deleted file mode 100644
index 385d154..0000000
--- a/build/map-key
+++ /dev/null
@@ -1,59 +0,0 @@
-// file : build/map-key -*- C++ -*-
-// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#ifndef BUILD_MAP_KEY
-#define BUILD_MAP_KEY
-
-#include <utility> // declval()
-#include <functional> // hash
-
-namespace build
-{
- // Google the "Emulating Boost.MultiIndex with Standard Containers" blog
- // post for deatils.
- //
-
- template <typename T>
- struct map_key
- {
- mutable const T* p;
-
- map_key (const T* v = 0): p (v) {}
- bool operator< (const map_key& x) const {return *p < *x.p;}
- bool operator== (const map_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::map_key<T>>: hash<T>
- {
- size_t
- operator() (build::map_key<T> x) const
- noexcept (noexcept (declval<hash<T>> () (*x.p)))
- {
- return hash<T>::operator() (*x.p);
- }
- };
-}
-
-#endif // BUILD_MAP_KEY