From 67b36b32e19e17db9b1e5c72deb8db7202a0f41b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 9 Aug 2018 09:36:23 +0200 Subject: Add support for returning optional from (buildfile) function implementations --- build2/variable.ixx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'build2/variable.ixx') diff --git a/build2/variable.ixx b/build2/variable.ixx index 8c16559..bf5fb92 100644 --- a/build2/variable.ixx +++ b/build2/variable.ixx @@ -24,6 +24,14 @@ namespace build2 new (&data_) names (move (ns)); } + inline value:: + value (optional ns) + : type (nullptr), null (!ns), extra (0) + { + if (!null) + new (&data_) names (move (*ns)); + } + template inline value:: value (T v) @@ -33,6 +41,18 @@ namespace build2 null = false; } + template + inline value:: + value (optional v) + : type (&value_traits::value_type), null (true), extra (0) + { + if (v) + { + value_traits::assign (*this, move (*v)); + null = false; + } + } + inline value& value:: operator= (reference_wrapper v) { -- cgit v1.1