aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/variable.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-09-30 15:10:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-09-30 15:30:55 +0200
commit16e74b781e0fafeed0312c9fa0fd1ae03cf432ea (patch)
tree606224d576d36b8c081c19122a9b7c63ee6a68a2 /libbuild2/variable.txx
parent15000dc770e864112aa83035a371117b9ca6e991 (diff)
Allow attributes in if-else, assert directive's conditions
Diffstat (limited to 'libbuild2/variable.txx')
-rw-r--r--libbuild2/variable.txx27
1 files changed, 20 insertions, 7 deletions
diff --git a/libbuild2/variable.txx b/libbuild2/variable.txx
index 9b7490a..92b7169 100644
--- a/libbuild2/variable.txx
+++ b/libbuild2/variable.txx
@@ -60,14 +60,27 @@ namespace build2
T
convert (value&& v)
{
- if (v.type == nullptr)
- return convert<T> (move (v).as<names> ());
- else if (v.type == &value_traits<T>::value_type)
- return move (v).as<T> ();
+ if (v)
+ {
+ if (v.type == nullptr)
+ return convert<T> (move (v).as<names> ());
+ else if (v.type == &value_traits<T>::value_type)
+ return move (v).as<T> ();
+ }
- throw invalid_argument (
- string ("invalid ") + value_traits<T>::value_type.name +
- " value: conversion from " + v.type->name);
+ string m ("invalid ");
+ m += value_traits<T>::value_type.name;
+ m += " value: ";
+
+ if (v)
+ {
+ m += "conversion from ";
+ m += v.type->name;
+ }
+ else
+ m += "null";
+
+ throw invalid_argument (move (m));
}
template <typename T>