aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/map-key59
-rw-r--r--build/string-table4
-rw-r--r--build/target6
3 files changed, 5 insertions, 64 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
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 <string>
#include <unordered_map>
-#include <build/map-key>
+#include <butl/multi-index>
namespace build
{
@@ -71,7 +71,7 @@ namespace build
empty () const {return vec_.empty ();}
private:
- using key_type = map_key<std::string>;
+ using key_type = butl::map_key<std::string>;
using value_type = string_table_element<I, D>;
using map_type = std::unordered_map<key_type, value_type>;
using traits = string_table_traits<D>;
diff --git a/build/target b/build/target
index 06aa227..d12a8e5 100644
--- a/build/target
+++ b/build/target
@@ -16,10 +16,10 @@
#include <utility> // move()
#include <iterator>
-#include <butl/utility> // compare_c_string
+#include <butl/utility> // compare_c_string
+#include <butl/multi-index> // map_iterator_adapter
#include <build/path>
-#include <build/map-key> // map_iterator_adapter
#include <build/timestamp>
#include <build/name>
#include <build/variable>
@@ -394,7 +394,7 @@ namespace build
struct target_set
{
typedef std::map<target_key, std::unique_ptr<target>> map;
- typedef map_iterator_adapter<map::const_iterator> iterator;
+ typedef butl::map_iterator_adapter<map::const_iterator> iterator;
iterator
find (const target_key& k, tracer& trace) const;