aboutsummaryrefslogtreecommitdiff
path: root/build2/variable
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-04 13:06:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-04 13:06:50 +0200
commit5c369faa461ec4416d2d4b231a5b36963a7315ce (patch)
treefc1b550870a29f0a03e258a76f16496ac69ec35c /build2/variable
parent0e486cd3642da8a442629ffce9a3daf16745c35e (diff)
Implement value typing, null support via value attributes
For example: v = [null] v = [string] abc v += ABC # abcABC
Diffstat (limited to 'build2/variable')
-rw-r--r--build2/variable10
1 files changed, 8 insertions, 2 deletions
diff --git a/build2/variable b/build2/variable
index 48acfea..10a0f59 100644
--- a/build2/variable
+++ b/build2/variable
@@ -120,14 +120,16 @@ namespace build2
//
//
public:
- ~value () {if (!null ()) *this = nullptr;}
+ ~value () {*this = nullptr;}
explicit
value (const value_type* t = nullptr)
: type (t), state (value_state::null) {}
+ // Note: preserves type.
+ //
value&
- operator= (nullptr_t);
+ operator= (nullptr_t) {if (!null ()) reset (); return *this;}
value (value&&);
explicit value (const value&);
@@ -185,6 +187,10 @@ namespace build2
// Make sure we have sufficient storage for untyped values.
//
static_assert (sizeof (names) <= size_, "insufficient space");
+
+ private:
+ void
+ reset ();
};
// The values should be of the same type (or both be untyped). NULL values