From 4cda4b89c16932f02e04c5019a71b659ccf821e6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Jun 2015 12:25:02 +0200 Subject: Move prefix-map from build2 to libbutl --- build/variable | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'build/variable') diff --git a/build/variable b/build/variable index 0cd411d..42f0787 100644 --- a/build/variable +++ b/build/variable @@ -14,9 +14,10 @@ #include #include +#include + #include #include -#include namespace build { @@ -207,24 +208,10 @@ namespace std }; } -namespace build +namespace butl { - // variable_pool - // - struct variable_set: std::unordered_set - { - // @@ Need to check/set type? - // - const variable& - find (std::string name) {return *emplace (std::move (name)).first;} - }; - - extern variable_set variable_pool; - - // variable_map - // template <> - struct compare_prefix: compare_prefix + struct compare_prefix: compare_prefix { typedef compare_prefix base; @@ -232,22 +219,38 @@ namespace build compare_prefix (char d): base (d) {} bool - operator() (const variable& x, const variable& y) const + operator() (const build::variable& x, const build::variable& y) const { return base::operator() (x.name, y.name); } bool - prefix (const variable& p, const variable& k) const + prefix (const build::variable& p, const build::variable& k) const { return base::prefix (p.name, k.name); } }; +} - struct variable_map: prefix_map +namespace build +{ + // variable_pool + // + struct variable_set: std::unordered_set { - typedef prefix_map base; + // @@ Need to check/set type? + // + const variable& + find (std::string name) {return *emplace (std::move (name)).first;} + }; + + extern variable_set variable_pool; + // variable_map + // + using variable_map_base = butl::prefix_map; + struct variable_map: variable_map_base + { value_proxy operator[] (const variable& var) const { @@ -268,7 +271,7 @@ namespace build value_proxy assign (const variable& var) { - return value_proxy (&base::operator[] (var), this); + return value_proxy (&variable_map_base::operator[] (var), this); } value_proxy -- cgit v1.1