From 6b7075adc71104c5f6ad652b99fb753565eb67d8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 18 Nov 2016 17:28:46 +0200 Subject: Add function machinery, implement path.normalize() Note that multi-argument functions are not yet "callable" since there is no support for value packs. --- build2/variable.txx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'build2/variable.txx') diff --git a/build2/variable.txx b/build2/variable.txx index 95e4f0a..7bb30e9 100644 --- a/build2/variable.txx +++ b/build2/variable.txx @@ -177,6 +177,35 @@ namespace build2 // template + vector value_traits>:: + convert (names&& ns) + { + vector v; + + // Similar to vector_append() below except we throw instead of issuing + // diagnostics. + // + for (auto i (ns.begin ()); i != ns.end (); ++i) + { + name& n (*i); + name* r (nullptr); + + if (n.pair) + { + r = &*++i; + + if (n.pair != '@') + throw invalid_argument ( + string ("invalid pair character: '") + n.pair + "'"); + } + + v.push_back (value_traits::convert (move (n), r)); + } + + return v; + } + + template void vector_append (value& v, names&& ns, const variable* var) { -- cgit v1.1