aboutsummaryrefslogtreecommitdiff
path: root/build/variable
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-08 14:40:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-08 14:40:15 +0200
commit650d61845b3f61e9596a8a2dc97458998ba26013 (patch)
treeb0ce0b66bfd053ffb38849589404957cde0f12dc /build/variable
parent402bb6e6b297614226c4f848ebdb13fd49a95d76 (diff)
Implement automatic amalgamation discovery
Diffstat (limited to 'build/variable')
-rw-r--r--build/variable15
1 files changed, 11 insertions, 4 deletions
diff --git a/build/variable b/build/variable
index 2164f92..064a10a 100644
--- a/build/variable
+++ b/build/variable
@@ -8,7 +8,7 @@
#include <string>
#include <memory> // unique_ptr
#include <cstddef> // nullptr_t
-#include <utility> // move()
+#include <utility> // move(), pair, make_pair()
#include <cassert>
#include <functional> // hash
#include <typeindex>
@@ -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<value_proxy, bool>
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<value_proxy, bool>
assign (const std::string& name)
{
return assign (variable_pool.find (name));