From e7a79b31eaca464f37d346ebeb26be9d9bb1437b Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Fri, 12 Feb 2016 21:06:06 +0900 Subject: [PATCH] partial support (C++11 constexpr) for VC++2015 --- sprout/cinttypes/div.hpp | 4 ++-- sprout/config/compiler/visualc.hpp | 6 +++++- sprout/config/suffix.hpp | 16 ++++++++++++---- sprout/cstdlib/div.hpp | 2 +- sprout/type/string/to_string.hpp | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/sprout/cinttypes/div.hpp b/sprout/cinttypes/div.hpp index 70279689..9ac69dc3 100644 --- a/sprout/cinttypes/div.hpp +++ b/sprout/cinttypes/div.hpp @@ -59,7 +59,7 @@ namespace sprout { typename sprout::detail::div_t_traits2::type >::type div_impl2(T const& numer, T const& denom) { -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER > 1900) typename sprout::detail::div_t_traits2::type result = {numer / denom, numer % denom}; return result; #else @@ -73,7 +73,7 @@ namespace sprout { typename sprout::detail::div_t_traits2::type >::type div_impl2(T const& numer, T const& denom) { -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER > 1900) typename sprout::detail::div_t_traits2::type result = {numer % denom, numer / denom}; return result; #else diff --git a/sprout/config/compiler/visualc.hpp b/sprout/config/compiler/visualc.hpp index 4f7fc2ee..a1e6f9b8 100644 --- a/sprout/config/compiler/visualc.hpp +++ b/sprout/config/compiler/visualc.hpp @@ -8,7 +8,11 @@ #ifndef SPROUT_CONFIG_COMPILER_VISUALC_HPP #define SPROUT_CONFIG_COMPILER_VISUALC_HPP -#define SPROUT_NO_CXX11_CONSTEXPR +#if _MSC_FULL_VER < 190023026 +# define SPROUT_NO_CXX11_CONSTEXPR +#endif +#define SPROUT_NO_STATIC_CONSTEXPR_INITIALIZATION + #if _MSC_FULL_VER < 180020827 # define SPROUT_NO_CXX11_DEFAULTED_FUNCTIONS # define SPROUT_NO_CXX11_DELETED_FUNCTIONS diff --git a/sprout/config/suffix.hpp b/sprout/config/suffix.hpp index d4f22c38..9697841f 100644 --- a/sprout/config/suffix.hpp +++ b/sprout/config/suffix.hpp @@ -17,11 +17,19 @@ // #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR # define SPROUT_CONSTEXPR constexpr -# define SPROUT_CONSTEXPR_OR_CONST constexpr -# define SPROUT_STATIC_CONSTEXPR static constexpr +# ifndef SPROUT_NO_STATIC_CONSTEXPR_INITIALIZATION +# define SPROUT_CONSTEXPR_OR_CONST constexpr +# define SPROUT_STATIC_CONSTEXPR static constexpr # -# define SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_INNER(EXPR) = EXPR -# define SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(EXPR) +# define SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_INNER(EXPR) = EXPR +# define SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(EXPR) +# else +# define SPROUT_CONSTEXPR_OR_CONST const +# define SPROUT_STATIC_CONSTEXPR static const +# +# define SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_INNER(EXPR) +# define SPROUT_STATIC_CONSTEXPR_DATA_MEMBER_OUTER(EXPR) = EXPR +# endif #else // #ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR # define SPROUT_CONSTEXPR # define SPROUT_CONSTEXPR_OR_CONST const diff --git a/sprout/cstdlib/div.hpp b/sprout/cstdlib/div.hpp index c5b482d4..fbf6b16b 100644 --- a/sprout/cstdlib/div.hpp +++ b/sprout/cstdlib/div.hpp @@ -56,7 +56,7 @@ namespace sprout { typename sprout::detail::div_t_traits::type >::type div_impl(T const& numer, T const& denom) { -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER > 1900) typename sprout::detail::div_t_traits::type result = {numer / denom, numer % denom}; return result; #else diff --git a/sprout/type/string/to_string.hpp b/sprout/type/string/to_string.hpp index d113aaa7..ade0c80c 100644 --- a/sprout/type/string/to_string.hpp +++ b/sprout/type/string/to_string.hpp @@ -23,7 +23,7 @@ namespace sprout { namespace types { -#ifndef SPROUT_CONFIG_DISABLE_CONSTEXPR +#if !defined(SPROUT_CONFIG_DISABLE_CONSTEXPR) && !defined(SPROUT_NO_STATIC_CONSTEXPR_INITIALIZATION) // // to_string //