diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-04 13:06:50 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-04 13:06:50 +0200 |
commit | 5c369faa461ec4416d2d4b231a5b36963a7315ce (patch) | |
tree | fc1b550870a29f0a03e258a76f16496ac69ec35c /build2/variable | |
parent | 0e486cd3642da8a442629ffce9a3daf16745c35e (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/variable | 10 |
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 |