From 3e1c01bb5f46ddd08e73b599c482fdfc5abf77ab Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 21 Nov 2016 12:43:26 +0200 Subject: Make types array in function machinery constexpr --- build2/function | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'build2/function') diff --git a/build2/function b/build2/function index c5cde27..32914dd 100644 --- a/build2/function +++ b/build2/function @@ -205,7 +205,7 @@ namespace build2 static const bool null = false; static const bool opt = false; - static optional + static constexpr optional type () {return &value_traits::value_type;} static T&& @@ -226,7 +226,7 @@ namespace build2 static const bool null = false; static const bool opt = false; - static optional + static constexpr optional type () {return nullptr;} static names&& @@ -245,7 +245,7 @@ namespace build2 static const bool null = false; static const bool opt = false; - static optional + static constexpr optional type () {return nullopt;} static value&& @@ -315,13 +315,26 @@ namespace build2 static const size_t max = sizeof...(A); static const size_t min = max - function_args_opt::count; + // VC14 doesn't realize that a pointer to static object (in our case it is + // &value_trair::value_type) is constexpr. + // +#if !defined(_MSC_VER) || _MSC_VER > 1900 + static constexpr const optional types[max] = { + function_arg::type ()...}; +#else static const optional types[max]; +#endif }; template +#if !defined(_MSC_VER) || _MSC_VER > 1900 + constexpr const optional + function_args::types[function_args::max]; +#else const optional function_args::types[function_args::max] = { function_arg::type ()...}; +#endif // Specialization for no arguments. // @@ -330,7 +343,12 @@ namespace build2 { static const size_t max = 0; static const size_t min = 0; - static const optional* const types; // NULL + +#if !defined(_MSC_VER) || _MSC_VER > 1900 + static constexpr const optional* types = nullptr; +#else + static const optional* const types; +#endif }; // Cast data/thunk. -- cgit v1.1