From 86db4fb7388285adc24e3aa6eb3f7ec68efd15f4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 28 Jun 2016 17:14:21 +0200 Subject: Work around static initialization order issue value_traits::value_type initialization is not constexpr in VC because of pointers to function template instantiations (which apparently are not constexpr). --- build2/variable.cxx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'build2/variable.cxx') diff --git a/build2/variable.cxx b/build2/variable.cxx index 17a9d52..65bc023 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -333,9 +333,11 @@ namespace build2 throw invalid_argument (string ()); } + constexpr const char* const value_traits::type_name = "bool"; + const value_type value_traits::value_type { - "bool", + type_name, sizeof (bool), nullptr, // No base. nullptr, // No dtor (POD). @@ -371,9 +373,11 @@ namespace build2 throw invalid_argument (string ()); } + constexpr const char* const value_traits::type_name = "uint64"; + const value_type value_traits::value_type { - "uint64", + type_name, sizeof (uint64_t), nullptr, // No base. nullptr, // No dtor (POD). @@ -455,9 +459,11 @@ namespace build2 return s; } + constexpr const char* const value_traits::type_name = "string"; + const value_type value_traits::value_type { - "string", + type_name, sizeof (string), nullptr, // No base. &default_dtor, @@ -498,9 +504,11 @@ namespace build2 throw invalid_argument (string ()); } + constexpr const char* const value_traits::type_name = "path"; + const value_type value_traits::value_type { - "path", + type_name, sizeof (path), nullptr, // No base. &default_dtor, @@ -539,9 +547,11 @@ namespace build2 throw invalid_argument (string ()); } + constexpr const char* const value_traits::type_name = "dir_path"; + const value_type value_traits::value_type { - "dir_path", + type_name, sizeof (dir_path), nullptr, // No base, or should it be path? &default_dtor, @@ -570,9 +580,12 @@ namespace build2 return abs_dir_path (move (d)); } + constexpr const char* const value_traits::type_name = + "abs_dir_path"; + const value_type value_traits::value_type { - "abs_dir_path", + type_name, sizeof (abs_dir_path), &value_traits::value_type, // Assume direct cast works for both. &default_dtor, @@ -603,9 +616,11 @@ namespace build2 return names_view (&v.as (), 1); } + constexpr const char* const value_traits::type_name = "name"; + const value_type value_traits::value_type { - "name", + type_name, sizeof (name), nullptr, // No base. &default_dtor, -- cgit v1.1