diff options
Diffstat (limited to 'libbuild2/scope.hxx')
-rw-r--r-- | libbuild2/scope.hxx | 20 |
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 |