From 16e74b781e0fafeed0312c9fa0fd1ae03cf432ea Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Sep 2019 15:10:24 +0200 Subject: Allow attributes in if-else, assert directive's conditions --- libbuild2/variable.txx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'libbuild2/variable.txx') 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 (move (v).as ()); - else if (v.type == &value_traits::value_type) - return move (v).as (); + if (v) + { + if (v.type == nullptr) + return convert (move (v).as ()); + else if (v.type == &value_traits::value_type) + return move (v).as (); + } - throw invalid_argument ( - string ("invalid ") + value_traits::value_type.name + - " value: conversion from " + v.type->name); + string m ("invalid "); + m += value_traits::value_type.name; + m += " value: "; + + if (v) + { + m += "conversion from "; + m += v.type->name; + } + else + m += "null"; + + throw invalid_argument (move (m)); } template -- cgit v1.1