diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-08 16:09:31 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-04-08 16:09:31 +0200 |
commit | 5af9070fda0dba591264ed675920efcfd62e81bc (patch) | |
tree | 8331fc83572c4bcd93a06adfcb489877b9816153 /build/variable | |
parent | 22a280a1f3f92c2e01ef192a4dda65e7ae957188 (diff) |
Distinguish between undefined and null variables
Diffstat (limited to 'build/variable')
-rw-r--r-- | build/variable | 10 |
1 files changed, 9 insertions, 1 deletions
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; |