From 79cb3221c2babe6f560f2e3e463e899631a32b33 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Nov 2016 14:58:30 +0200 Subject: Implement few builtin functions that can operate on any value type() null() empty () identity() --- build2/function | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'build2/function') 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 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 - 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: function_arg + { + static const bool null = true; + + static value* + cast (value* v) {return v;} // NULL indicator in value::null. + }; + template struct function_arg>: function_arg { -- cgit v1.1