diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-16 10:53:39 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-18 17:30:47 +0200 |
commit | aeeedd32f8717d8c6a1886a5561a879059be87d0 (patch) | |
tree | cdd4c893e05a1e950f689443ac63f532df721352 /build2/variable.ixx | |
parent | a7efabf301f23364ac2335c80c5e1e712bc43204 (diff) |
Make names and vector<name> different types, add typed value constructor
Diffstat (limited to 'build2/variable.ixx')
-rw-r--r-- | build2/variable.ixx | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/build2/variable.ixx b/build2/variable.ixx index 5c9118b..d054dd4 100644 --- a/build2/variable.ixx +++ b/build2/variable.ixx @@ -12,8 +12,9 @@ namespace build2 empty () const { assert (!null); - return type == nullptr ? as<names> ().empty () : - type->empty == nullptr ? false : type->empty (*this); + return type == nullptr + ? as<names> ().empty () + : type->empty == nullptr ? false : type->empty (*this); } inline value:: @@ -23,6 +24,15 @@ namespace build2 new (&data_) names (move (ns)); } + template <typename T> + inline value:: + value (T v) + : type (&value_traits<T>::value_type), null (true), extra (0) + { + value_traits<T>::assign (*this, move (v)); + null = false; + } + inline value& value:: operator= (reference_wrapper<value> v) { @@ -93,10 +103,7 @@ namespace build2 inline const names& cast (const value& v) { - // Note that it can still be a typed vector<names>. - // - assert (v && - (v.type == nullptr || v.type == &value_traits<names>::value_type)); + assert (v && v.type == nullptr); return v.as<names> (); } @@ -104,8 +111,7 @@ namespace build2 inline names& cast (value& v) { - assert (v && - (v.type == nullptr || v.type == &value_traits<names>::value_type)); + assert (v && v.type == nullptr); return v.as<names> (); } @@ -230,7 +236,6 @@ namespace build2 v.as<bool> () = x; else new (&v.data_) bool (x); - } inline void value_traits<bool>:: |