From 2c8294b069f5df30d281e0f4f580f6f313a50eb2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 4 Dec 2017 12:39:33 +0200 Subject: Add cast_empty() for value casting --- build2/variable.ixx | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'build2/variable.ixx') diff --git a/build2/variable.ixx b/build2/variable.ixx index 6126a4e..634e3dc 100644 --- a/build2/variable.ixx +++ b/build2/variable.ixx @@ -187,21 +187,46 @@ namespace build2 } template - inline T - cast_false (const value& v) {return v && cast (v);} + inline const T& + cast_empty (const value& v) + { + return v ? cast (v) : value_traits::empty_instance; + } + + template + inline const T& + cast_empty (const lookup& l) + { + return l ? cast (l) : value_traits::empty_instance; + } template inline T - cast_false (const lookup& l) {return l && cast (l);} + cast_false (const value& v) + { + return v && cast (v); + } template inline T - cast_true (const value& v) {return !v || cast (v);} + cast_false (const lookup& l) + { + return l && cast (l); + } template inline T - cast_true (const lookup& l) {return !l || cast (l);} + cast_true (const value& v) + { + return !v || cast (v); + } + template + inline T + cast_true (const lookup& l) + { + return !l || cast (l); + } template inline void -- cgit v1.1