aboutsummaryrefslogtreecommitdiff
path: root/build2/function
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-23 14:58:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-23 14:58:30 +0200
commit79cb3221c2babe6f560f2e3e463e899631a32b33 (patch)
tree2135159931dde6acde213d6e8de1bdbd06d222d4 /build2/function
parentc6265603e0e98c19f8d81c8edd5a34a550063c02 (diff)
Implement few builtin functions that can operate on any value
type() null() empty () identity()
Diffstat (limited to 'build2/function')
-rw-r--r--build2/function12
1 files changed, 11 insertions, 1 deletions
diff --git a/build2/function b/build2/function
index 68edcde..192c4a3 100644
--- a/build2/function
+++ b/build2/function
@@ -37,7 +37,8 @@ namespace build2
// T - statically-typed (value_traits<T> must be defined)
// names - untyped
// value - any type
- // T* - NULL-able argument (here T can be names, value).
+ // T* - NULL-able argument (here T can be names)
+ // value* - NULL-able any type (never NULL itself, use value::null)
// optional<T> - optional argument (here T can be T*, names, value)
//
// Optional arguments must be last. In case of a failure the function is
@@ -281,6 +282,15 @@ namespace build2
}
};
+ template <>
+ struct function_arg<value*>: function_arg<value>
+ {
+ static const bool null = true;
+
+ static value*
+ cast (value* v) {return v;} // NULL indicator in value::null.
+ };
+
template <typename T>
struct function_arg<optional<T>>: function_arg<T>
{