aboutsummaryrefslogtreecommitdiff
path: root/build2/function
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-21 12:43:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-21 12:43:26 +0200
commit3e1c01bb5f46ddd08e73b599c482fdfc5abf77ab (patch)
tree9d9b3495ae17f2c15e0ab49c1ca27404bc1e7be9 /build2/function
parent7a528eab1561b0d0d4ec29f98355fe67025ea632 (diff)
Make types array in function machinery constexpr
Diffstat (limited to 'build2/function')
-rw-r--r--build2/function26
1 files changed, 22 insertions, 4 deletions
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<const value_type*>
+ static constexpr optional<const value_type*>
type () {return &value_traits<T>::value_type;}
static T&&
@@ -226,7 +226,7 @@ namespace build2
static const bool null = false;
static const bool opt = false;
- static optional<const value_type*>
+ static constexpr optional<const value_type*>
type () {return nullptr;}
static names&&
@@ -245,7 +245,7 @@ namespace build2
static const bool null = false;
static const bool opt = false;
- static optional<const value_type*>
+ static constexpr optional<const value_type*>
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<A...>::count;
+ // VC14 doesn't realize that a pointer to static object (in our case it is
+ // &value_trair<T>::value_type) is constexpr.
+ //
+#if !defined(_MSC_VER) || _MSC_VER > 1900
+ static constexpr const optional<const value_type*> types[max] = {
+ function_arg<A>::type ()...};
+#else
static const optional<const value_type*> types[max];
+#endif
};
template <typename... A>
+#if !defined(_MSC_VER) || _MSC_VER > 1900
+ constexpr const optional<const value_type*>
+ function_args<A...>::types[function_args<A...>::max];
+#else
const optional<const value_type*>
function_args<A...>::types[function_args<A...>::max] = {
function_arg<A>::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 value_type*>* const types; // NULL
+
+#if !defined(_MSC_VER) || _MSC_VER > 1900
+ static constexpr const optional<const value_type*>* types = nullptr;
+#else
+ static const optional<const value_type*>* const types;
+#endif
};
// Cast data/thunk.