From 28c82c861e38fe05a25e916563e0551ed8fce91e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Jun 2015 12:32:55 +0200 Subject: Move map-key from build2 to libbutl, rename multi-index --- build/map-key | 59 ------------------------------------------------------ build/string-table | 4 ++-- build/target | 6 +++--- 3 files changed, 5 insertions(+), 64 deletions(-) delete mode 100644 build/map-key (limited to 'build') 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 // declval() -#include // hash - -namespace build -{ - // Google the "Emulating Boost.MultiIndex with Standard Containers" blog - // post for deatils. - // - - template - 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 - 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 (*this) = i; return *this;} - - reference operator* () const {return I::operator* ().second;} - pointer operator-> () const {return &I::operator-> ()->second;} - }; -} - -namespace std -{ - template - struct hash>: hash - { - size_t - operator() (build::map_key x) const - noexcept (noexcept (declval> () (*x.p))) - { - return hash::operator() (*x.p); - } - }; -} - -#endif // BUILD_MAP_KEY diff --git a/build/string-table b/build/string-table index a4fae36..0188c62 100644 --- a/build/string-table +++ b/build/string-table @@ -9,7 +9,7 @@ #include #include -#include +#include namespace build { @@ -71,7 +71,7 @@ namespace build empty () const {return vec_.empty ();} private: - using key_type = map_key; + using key_type = butl::map_key; using value_type = string_table_element; using map_type = std::unordered_map; using traits = string_table_traits; diff --git a/build/target b/build/target index 06aa227..d12a8e5 100644 --- a/build/target +++ b/build/target @@ -16,10 +16,10 @@ #include // move() #include -#include // compare_c_string +#include // compare_c_string +#include // map_iterator_adapter #include -#include // map_iterator_adapter #include #include #include @@ -394,7 +394,7 @@ namespace build struct target_set { typedef std::map> map; - typedef map_iterator_adapter iterator; + typedef butl::map_iterator_adapter iterator; iterator find (const target_key& k, tracer& trace) const; -- cgit v1.1