From 5af9070fda0dba591264ed675920efcfd62e81bc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 8 Apr 2015 16:09:31 +0200 Subject: Distinguish between undefined and null variables --- build/variable | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'build/variable') diff --git a/build/variable b/build/variable index fc0ba2b..67ec33c 100644 --- a/build/variable +++ b/build/variable @@ -90,11 +90,19 @@ namespace build // value_proxy // + // A variable can be undefined, null, or contain some actual value. + // struct value_proxy { typedef build::scope scope_type; - explicit operator bool () const {return p != nullptr && *p != nullptr;} + bool + defined () const {return p != nullptr;} + + bool + null () const {return *p == nullptr;} + + explicit operator bool () const {return defined () && !null ();} explicit operator value_ptr& () const {return *p;} scope_type* scope; -- cgit v1.1