From 20677fb264e743b8e5423af31a7d8dc06cf509f6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 16 Mar 2016 15:27:12 +0200 Subject: Cleanup typed variable assignment --- build2/variable | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'build2/variable') diff --git a/build2/variable b/build2/variable index 0c945c7..1a52566 100644 --- a/build2/variable +++ b/build2/variable @@ -161,6 +161,12 @@ namespace build2 inline bool operator!= (const value& x, const value& y) {return !(x == y);} + // Assign value type to the value. This triggers the assign callback. + // + template + void assign (value&, const variable&); + void assign (value&, const value_type*, const variable&); + // lookup // // A variable can be undefined, NULL, or contain a (potentially @@ -203,12 +209,8 @@ namespace build2 // template struct value_traits; - // Assign value type to the value. + // Value cast. // - template - void assign (value&, const variable&); - void assign (value&, const value_type*, const variable&); - template typename value_traits::type as (value&); template typename value_traits::const_type as (const value&); @@ -758,8 +760,8 @@ namespace build2 return operator[] (var_pool.find (name)); } - // The second member in the pair indicates whether the new - // value (which will be NULL) was assigned. + // The second member in the pair indicates whether the new value (which + // will be NULL) was assigned. // pair, bool> assign (const variable& var) @@ -781,6 +783,13 @@ namespace build2 return assign (var_pool.find (name, type)); } + template + pair, bool> + assign (const string& name) + { + return assign (var_pool.find (name, &value_traits::value_type)); + } + pair find_namespace (const string& ns) const { -- cgit v1.1