From b86c1d8d2e0be140f6854d869e07139ff3c4221c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 Aug 2020 10:51:26 +0200 Subject: Add copying version of convert(value) --- libbuild2/variable.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libbuild2/variable.cxx') diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx index a4c3ef3..91b25bd 100644 --- a/libbuild2/variable.cxx +++ b/libbuild2/variable.cxx @@ -410,6 +410,24 @@ namespace build2 v.assign (move (ns), nullptr); // Assign new data. } + [[noreturn]] void + convert_throw (const value_type* from, const value_type& to) + { + string m ("invalid "); + m += to.name; + m += " value: "; + + if (from != nullptr) + { + m += "conversion from "; + m += from->name; + } + else + m += "null"; + + throw invalid_argument (move (m)); + } + // Throw invalid_argument for an invalid simple value. // [[noreturn]] static void -- cgit v1.1