diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-12-04 12:39:33 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-12-04 12:39:33 +0200 |
commit | 2c8294b069f5df30d281e0f4f580f6f313a50eb2 (patch) | |
tree | fe398543c4fa8565039651643fa2f51bbbe9999c /build2/variable.hxx | |
parent | 6d58efb0a5ca051bb205812edd130573bf3c39ce (diff) |
Add cast_empty() for value casting
Diffstat (limited to 'build2/variable.hxx')
-rw-r--r-- | build2/variable.hxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/build2/variable.hxx b/build2/variable.hxx index c5e1a13..9a58584 100644 --- a/build2/variable.hxx +++ b/build2/variable.hxx @@ -289,6 +289,12 @@ namespace build2 template <typename T> const T* cast_null (const value&); template <typename T> const T* cast_null (const lookup&); + // As above but returns empty value if the value is NULL (or not defined, in + // case of lookup). + // + template <typename T> const T& cast_empty (const value&); + template <typename T> const T& cast_empty (const lookup&); + // As above but returns false/true if the value is NULL (or not defined, // in case of lookup). Note that the template argument is only for // documentation and should be bool (or semantically compatible). @@ -433,6 +439,8 @@ namespace build2 // // // static const bool empty_value = true; // + // static const T empty_instance; + // // // For simple types (those that can be used as elements of containers), // // type_name must be constexpr in order to sidestep the static init // // order issue (in fact, that's the only reason we have it both here @@ -579,6 +587,7 @@ namespace build2 static bool empty (const string& x) {return x.empty ();} static const bool empty_value = true; + static const string& empty_instance; static const char* const type_name; static const build2::value_type value_type; }; @@ -608,6 +617,7 @@ namespace build2 static bool empty (const path& x) {return x.empty ();} static const bool empty_value = true; + static const path& empty_instance; static const char* const type_name; static const build2::value_type value_type; }; @@ -628,6 +638,7 @@ namespace build2 static bool empty (const dir_path& x) {return x.empty ();} static const bool empty_value = true; + static const dir_path& empty_instance; static const char* const type_name; static const build2::value_type value_type; }; |