From 650d61845b3f61e9596a8a2dc97458998ba26013 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 8 Jul 2015 14:40:15 +0200 Subject: Implement automatic amalgamation discovery --- build/variable | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'build/variable') diff --git a/build/variable b/build/variable index 2164f92..064a10a 100644 --- a/build/variable +++ b/build/variable @@ -8,7 +8,7 @@ #include #include // unique_ptr #include // nullptr_t -#include // move() +#include // move(), pair, make_pair() #include #include // hash #include @@ -104,6 +104,9 @@ namespace build bool null () const {return *p == nullptr;} + bool + empty () const; + explicit operator bool () const {return defined () && !null ();} explicit operator value_ptr& () const {return *p;} @@ -267,13 +270,17 @@ namespace build return operator[] (variable_pool.find (name)); } - value_proxy + // The second member in the pair indicates whether new (NULL) + // value was set. + // + std::pair assign (const variable& var) { - return value_proxy (&variable_map_base::operator[] (var), this); + auto r (emplace (var, value_ptr ())); + return std::make_pair (value_proxy (&r.first->second, this), r.second); } - value_proxy + std::pair assign (const std::string& name) { return assign (variable_pool.find (name)); -- cgit v1.1