aboutsummaryrefslogtreecommitdiff
path: root/build/key-set
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-02-23 15:56:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-02-23 15:56:03 +0200
commitfefe0657f29b8db782f7a722dd46b074b991cf08 (patch)
tree62008e350c4f6048a68444fe50c47281643d276a /build/key-set
parent962cb1040670977085f0a187ecc6730608578151 (diff)
Redo rule match/build logic
Now the rule is fully responsible for searching, matching, and building of prerequisites.
Diffstat (limited to 'build/key-set')
-rw-r--r--build/key-set41
1 files changed, 41 insertions, 0 deletions
diff --git a/build/key-set b/build/key-set
new file mode 100644
index 0000000..9cb7d6c
--- /dev/null
+++ b/build/key-set
@@ -0,0 +1,41 @@
+// 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
+
+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;}
+ };
+
+ 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;}
+ };
+}
+
+#endif // BUILD_KEY_SET