From 1f482c4fa1d8fc66dc34776b04414f660cc66e76 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 28 Dec 2013 23:29:09 -0500 Subject: [PATCH 1/4] Add constexpr to conversion operator for integral constants --- include/boost/mpl/aux_/integral_wrapper.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/mpl/aux_/integral_wrapper.hpp b/include/boost/mpl/aux_/integral_wrapper.hpp index 6b5962e..6bc05f7 100644 --- a/include/boost/mpl/aux_/integral_wrapper.hpp +++ b/include/boost/mpl/aux_/integral_wrapper.hpp @@ -77,7 +77,7 @@ struct AUX_WRAPPER_NAME // functions that return objects of both arithmetic ('int', 'long', // 'double', etc.) and wrapped integral types (for an example, see // "mpl/example/power.cpp") - operator AUX_WRAPPER_VALUE_TYPE() const { return static_cast(this->value); } + BOOST_CONSTEXPR operator AUX_WRAPPER_VALUE_TYPE() const { return static_cast(this->value); } }; #if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) From ed58434c88ac03816fa0d232c679d551987b42a9 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 29 Dec 2013 05:46:32 -0500 Subject: [PATCH 2/4] Add constexpr to conversion operator for bool integral constants --- include/boost/mpl/bool.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/mpl/bool.hpp b/include/boost/mpl/bool.hpp index f4bb485..0a6180c 100644 --- a/include/boost/mpl/bool.hpp +++ b/include/boost/mpl/bool.hpp @@ -26,7 +26,7 @@ template< bool C_ > struct bool_ typedef integral_c_tag tag; typedef bool_ type; typedef bool value_type; - operator bool() const { return this->value; } + BOOST_CONSTEXPR operator bool() const { return this->value; } }; #if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) From f976861e13f0bb37dd6380c02ccc0d42140daebe Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 16 May 2014 02:38:50 -0400 Subject: [PATCH 3/4] Add test for constexpr conversion operator --- test/bool.cpp | 7 +++++++ test/integral_wrapper_test.hpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/test/bool.cpp b/test/bool.cpp index 8fad753..e023c0c 100644 --- a/test/bool.cpp +++ b/test/bool.cpp @@ -16,11 +16,18 @@ #include +#if defined(BOOST_NO_CXX11_CONSTEXPR) +#define CONSTEXPR_BOOL_TEST(c) +#else +#define CONSTEXPR_BOOL_TEST(c) { static_assert(bool_() == c, "Constexpr for bool_ failed"); } +#endif + #define BOOL_TEST(c) \ { MPL_ASSERT(( is_same< bool_::value_type, bool > )); } \ { MPL_ASSERT(( is_same< bool_, c##_ > )); } \ { MPL_ASSERT(( is_same< bool_::type, bool_ > )); } \ { MPL_ASSERT_RELATION( bool_::value, ==, c ); } \ + CONSTEXPR_BOOL_TEST(c) \ BOOST_TEST( bool_() == c ); \ /**/ diff --git a/test/integral_wrapper_test.hpp b/test/integral_wrapper_test.hpp index 4a08d3c..be31d50 100644 --- a/test/integral_wrapper_test.hpp +++ b/test/integral_wrapper_test.hpp @@ -28,6 +28,12 @@ /**/ #endif +#if defined(BOOST_NO_CXX11_CONSTEXPR) +#define CONSTEXPR_INTEGRAL_TEST(T, i) +#else +#define CONSTEXPR_INTEGRAL_TEST(T, i) { static_assert(T() == i, "Constexpr for integral constant failed"); } +#endif + #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) // agurt 20/nov/06: see http://article.gmane.org/gmane.comp.lib.boost.devel/151065 #define INTEGRAL_WRAPPER_TEST(unused1, i, T) \ @@ -39,6 +45,7 @@ { MPL_ASSERT(( is_same< next< borland_tested_type >::type, WRAPPER(T,i+1) > )); } \ { MPL_ASSERT(( is_same< prior< borland_tested_type >::type, WRAPPER(T,i-1) > )); } \ { MPL_ASSERT_RELATION( (borland_tested_type::value), ==, i ); } \ + CONSTEXPR_INTEGRAL_TEST(borland_tested_type, i) \ INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \ } \ /**/ @@ -49,6 +56,7 @@ { MPL_ASSERT(( is_same< next< WRAPPER(T,i) >::type, WRAPPER(T,i+1) > )); } \ { MPL_ASSERT(( is_same< prior< WRAPPER(T,i) >::type, WRAPPER(T,i-1) > )); } \ { MPL_ASSERT_RELATION( (WRAPPER(T,i)::value), ==, i ); } \ + CONSTEXPR_INTEGRAL_TEST(WRAPPER(T,i), i) \ INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \ /**/ #endif From 0b6167c84083107fa8e5ec897685fc0b1da2f725 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 5 Jun 2014 00:23:41 +0300 Subject: [PATCH 4/4] Remove dependency on Detail by using Predef directly. --- include/boost/mpl/string.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/mpl/string.hpp b/include/boost/mpl/string.hpp index c62d8ab..345918f 100644 --- a/include/boost/mpl/string.hpp +++ b/include/boost/mpl/string.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -59,7 +59,7 @@ namespace boost { namespace mpl #define BOOST_MPL_MULTICHAR_LENGTH(c) \ (std::size_t)((c0xffffff)+(c>0xffff)+(c>0xff)+1)) - #if defined(BOOST_LITTLE_ENDIAN) && defined(__SUNPRO_CC) + #if defined(BOOST_ENDIAN_LITTLE_BYTE) && defined(__SUNPRO_CC) #define BOOST_MPL_MULTICHAR_AT(c,i) \ (char)(0xff&((unsigned)(c)>>(8*(std::size_t)(i))))