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{
57
57
typedef integral_constant<T, val> type;
58
58
static const T value = val;
59
59
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>(); }
66
62
BOOST_CONSTEXPR operator T ()const { return val; }
67
63
};
68
64
@@ -77,12 +73,8 @@ namespace boost{
77
73
typedef integral_constant<bool , val> type;
78
74
static const bool value = val;
79
75
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>(); }
86
78
BOOST_CONSTEXPR operator bool ()const { return val; }
87
79
};
88
80
Original file line number Diff line number Diff line change 5
5
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
6
7
7
#include < boost/type_traits/is_void.hpp>
8
+ #include < boost/mpl/bool.hpp>
9
+ #include < boost/config.hpp>
8
10
9
11
template <class T >
10
- int dispatch_test_imp (const boost::mpl::bool_<true >&)
12
+ BOOST_CONSTEXPR int dispatch_test_imp1 (const boost::mpl::bool_<true >&)
11
13
{
12
14
return 0 ;
13
15
}
14
16
template <class T >
15
- int dispatch_test_imp (const boost::mpl::bool_<false >&)
17
+ BOOST_CONSTEXPR int dispatch_test_imp1 (const boost::mpl::bool_<false >&)
16
18
{
17
19
return 1 ;
18
20
}
19
21
20
22
template <class T >
21
- int dispatch_test ( )
23
+ BOOST_CONSTEXPR int dispatch_test_imp2 (boost::mpl::true_ )
22
24
{
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>());
24
38
}
25
39
26
40
27
41
int main ()
28
42
{
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 ;
30
45
}
You can’t perform that action at this time.
0 commit comments