diff --git a/include/boost/type_traits/integral_constant.hpp b/include/boost/type_traits/integral_constant.hpp index 1b36dbd2c3..954a2e38e2 100644 --- a/include/boost/type_traits/integral_constant.hpp +++ b/include/boost/type_traits/integral_constant.hpp @@ -57,12 +57,8 @@ namespace boost{ typedef integral_constant type; static const T value = val; - operator const mpl::integral_c& ()const - { - static const char data[sizeof(long)] = { 0 }; - static const void* pdata = data; - return *(reinterpret_cast*>(pdata)); - } + BOOST_CONSTEXPR operator mpl::integral_c()const + { return mpl::integral_c(); } BOOST_CONSTEXPR operator T()const { return val; } }; @@ -77,12 +73,8 @@ namespace boost{ typedef integral_constant type; static const bool value = val; - operator const mpl::bool_& ()const - { - static const char data[sizeof(long)] = { 0 }; - static const void* pdata = data; - return *(reinterpret_cast*>(pdata)); - } + BOOST_CONSTEXPR operator mpl::bool_()const + { return mpl::bool_(); } BOOST_CONSTEXPR operator bool()const { return val; } }; diff --git a/test/mpl_interop_test1.cpp b/test/mpl_interop_test1.cpp index 3b90418e9e..2e6c1704e5 100644 --- a/test/mpl_interop_test1.cpp +++ b/test/mpl_interop_test1.cpp @@ -5,26 +5,41 @@ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include +#include template -int dispatch_test_imp(const boost::mpl::bool_&) +BOOST_CONSTEXPR int dispatch_test_imp1(const boost::mpl::bool_&) { return 0; } template -int dispatch_test_imp(const boost::mpl::bool_&) +BOOST_CONSTEXPR int dispatch_test_imp1(const boost::mpl::bool_&) { return 1; } template -int dispatch_test() +BOOST_CONSTEXPR int dispatch_test_imp2(boost::mpl::true_) { - return dispatch_test_imp(boost::is_void()); + return 0; +} +template +BOOST_CONSTEXPR int dispatch_test_imp2(boost::mpl::false_) +{ + return 1; +} + +template +BOOST_CONSTEXPR int dispatch_test() +{ + return dispatch_test_imp1(boost::is_void()) + + dispatch_test_imp2(boost::is_void()); } int main() { - return (dispatch_test() == 1) && (dispatch_test() == 0) ? 0 : 1; + BOOST_CONSTEXPR bool result = (dispatch_test() == 2) && (dispatch_test() == 0); + return result ? 0 : 1; }