aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/scope.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-30 15:30:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-31 07:32:46 +0200
commitdfb51bc816cde2cb345f8a0300205e6ac95a2065 (patch)
treead5996b87bb3829f7058aa990fab65940b575249 /libbuild2/scope.hxx
parent65340a0a897c91b580db1de0bab026a0814c5d74 (diff)
Switch to project variable visibility by default
Diffstat (limited to 'libbuild2/scope.hxx')
-rw-r--r--libbuild2/scope.hxx20
1 files changed, 19 insertions, 1 deletions
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 <typename T>
value&
@@ -210,6 +212,22 @@ namespace build2
return v.as<T> ();
}
+ template <typename T>
+ T&
+ assign (const variable& var, T&& val)
+ {
+ value& v (assign (var) = forward<T> (val));
+ return v.as<T> ();
+ }
+
+ template <typename T>
+ T&
+ assign (const variable* var, T&& val)
+ {
+ value& v (assign (var) = forward<T> (val));
+ return v.as<T> ();
+ }
+
// 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