aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.ixx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/variable.ixx')
-rw-r--r--build2/variable.ixx23
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>::