From dfb51bc816cde2cb345f8a0300205e6ac95a2065 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Mar 2020 15:30:08 +0200 Subject: Switch to project variable visibility by default --- libbuild2/scope.hxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'libbuild2/scope.hxx') diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index cb20f79..39be143 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -187,13 +187,15 @@ namespace build2 value& assign (const variable* var) {return vars.assign (var);} // For cached. + // Assign an untyped non-overridable variable with project visibility. + // value& assign (string name) { return assign (var_pool ().insert (move (name))); } - // Assign a typed non-overridable variable with normal visibility. + // As above, but assign a typed variable. // template value& @@ -210,6 +212,22 @@ namespace build2 return v.as (); } + template + T& + assign (const variable& var, T&& val) + { + value& v (assign (var) = forward (val)); + return v.as (); + } + + template + T& + assign (const variable* var, T&& val) + { + value& v (assign (var) = forward (val)); + return v.as (); + } + // Return a value suitable for appending. If the variable does not // exist in this scope's map, then outer scopes are searched for // the same variable. If found then a new variable with the found -- cgit v1.1