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/functions-builtin.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 build2/functions-builtin.cxx (limited to 'build2/functions-builtin.cxx') diff --git a/build2/functions-builtin.cxx b/build2/functions-builtin.cxx new file mode 100644 index 0000000..448bb53 --- /dev/null +++ b/build2/functions-builtin.cxx @@ -0,0 +1,24 @@ +// file : build2/functions-builtin.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include +#include + +using namespace std; + +namespace build2 +{ + void + builtin_functions () + { + function_family f ("builtin"); + + f["type"] = [](value* v) {return v->type != nullptr ? v->type->name : "";}; + + f["null"] = [](value* v) {return v->null;}; + f["empty"] = [](value v) {return v.empty ();}; + + f["identity"] = [](value* v) {return move (*v);}; + } +} -- cgit v1.1