File tree Expand file tree Collapse file tree 2 files changed +24
-17
lines changed
include/boost/type_traits Expand file tree Collapse file tree 2 files changed +24
-17
lines changed Original file line number Diff line number Diff line change @@ -57,12 +57,8 @@ namespace boost{
5757 typedef integral_constant<T, val> type;
5858 static const T value = val;
5959
60- operator const mpl::integral_c<T, val>& ()const
61- {
62- static const char data[sizeof (long )] = { 0 };
63- static const void * pdata = data;
64- return *(reinterpret_cast <const mpl::integral_c<T, val>*>(pdata));
65- }
60+ BOOST_CONSTEXPR operator mpl::integral_c<T, val>()const
61+ { return mpl::integral_c<T, val>(); }
6662 BOOST_CONSTEXPR operator T ()const { return val; }
6763 };
6864
@@ -77,12 +73,8 @@ namespace boost{
7773 typedef integral_constant<bool , val> type;
7874 static const bool value = val;
7975
80- operator const mpl::bool_<val>& ()const
81- {
82- static const char data[sizeof (long )] = { 0 };
83- static const void * pdata = data;
84- return *(reinterpret_cast <const mpl::bool_<val>*>(pdata));
85- }
76+ BOOST_CONSTEXPR operator mpl::bool_<val>()const
77+ { return mpl::bool_<val>(); }
8678 BOOST_CONSTEXPR operator bool ()const { return val; }
8779 };
8880
Original file line number Diff line number Diff line change 55// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66
77#include < boost/type_traits/is_void.hpp>
8+ #include < boost/mpl/bool.hpp>
9+ #include < boost/config.hpp>
810
911template <class T >
10- int dispatch_test_imp (const boost::mpl::bool_<true >&)
12+ BOOST_CONSTEXPR int dispatch_test_imp1 (const boost::mpl::bool_<true >&)
1113{
1214 return 0 ;
1315}
1416template <class T >
15- int dispatch_test_imp (const boost::mpl::bool_<false >&)
17+ BOOST_CONSTEXPR int dispatch_test_imp1 (const boost::mpl::bool_<false >&)
1618{
1719 return 1 ;
1820}
1921
2022template <class T >
21- int dispatch_test ( )
23+ BOOST_CONSTEXPR int dispatch_test_imp2 (boost::mpl::true_ )
2224{
23- return dispatch_test_imp<T>(boost::is_void<T>());
25+ return 0 ;
26+ }
27+ template <class T >
28+ BOOST_CONSTEXPR int dispatch_test_imp2 (boost::mpl::false_)
29+ {
30+ return 1 ;
31+ }
32+
33+ template <class T >
34+ BOOST_CONSTEXPR int dispatch_test ()
35+ {
36+ return dispatch_test_imp1<T>(boost::is_void<T>()) +
37+ dispatch_test_imp2<T>(boost::is_void<T>());
2438}
2539
2640
2741int main ()
2842{
29- return (dispatch_test<int >() == 1 ) && (dispatch_test<void >() == 0 ) ? 0 : 1 ;
43+ BOOST_CONSTEXPR bool result = (dispatch_test<int >() == 2 ) && (dispatch_test<void >() == 0 );
44+ return result ? 0 : 1 ;
3045}
You can’t perform that action at this time.
0 commit comments