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.ixx | |
parent | 6d58efb0a5ca051bb205812edd130573bf3c39ce (diff) |
Add cast_empty() for value casting
Diffstat (limited to 'build2/variable.ixx')
-rw-r--r-- | build2/variable.ixx | 35 |
1 files changed, 30 insertions, 5 deletions
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 <typename T> - inline T - cast_false (const value& v) {return v && cast<T> (v);} + inline const T& + cast_empty (const value& v) + { + return v ? cast<T> (v) : value_traits<T>::empty_instance; + } + + template <typename T> + inline const T& + cast_empty (const lookup& l) + { + return l ? cast<T> (l) : value_traits<T>::empty_instance; + } template <typename T> inline T - cast_false (const lookup& l) {return l && cast<T> (l);} + cast_false (const value& v) + { + return v && cast<T> (v); + } template <typename T> inline T - cast_true (const value& v) {return !v || cast<T> (v);} + cast_false (const lookup& l) + { + return l && cast<T> (l); + } template <typename T> inline T - cast_true (const lookup& l) {return !l || cast<T> (l);} + cast_true (const value& v) + { + return !v || cast<T> (v); + } + template <typename T> + inline T + cast_true (const lookup& l) + { + return !l || cast<T> (l); + } template <typename T> inline void |