2 // (C) Copyright John Maddock 2000.
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #include "check_integral_constant.hpp"
10 # include <type_traits>
12 # include <boost/type_traits/has_nothrow_constructor.hpp>
18 bug11324_base
& operator=(const bug11324_base
&){ throw int(); }
19 virtual ~bug11324_base() {}
22 class bug11324_derived
: public bug11324_base
26 explicit bug11324_derived(char arg
) : data(arg
) {}
29 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
31 struct deleted_default_construct
33 deleted_default_construct() = delete;
34 deleted_default_construct(char val
) : member(val
) {}
40 struct private_default_construct
43 private_default_construct();
45 private_default_construct(char val
) : member(val
) {}
49 #ifndef BOOST_NO_CXX11_NOEXCEPT
50 struct noexcept_default_construct
52 noexcept_default_construct()noexcept
;
53 noexcept_default_construct(char val
)noexcept
: member(val
) {}
59 TT_TEST_BEGIN(has_nothrow_constructor
)
61 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<bool>::value
, true);
62 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<bool const>::value
, true);
63 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<bool volatile>::value
, true);
64 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<bool const volatile>::value
, true);
66 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<signed char>::value
, true);
67 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<signed char const>::value
, true);
68 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<signed char volatile>::value
, true);
69 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<signed char const volatile>::value
, true);
70 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned char>::value
, true);
71 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<char>::value
, true);
72 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned char const>::value
, true);
73 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<char const>::value
, true);
74 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned char volatile>::value
, true);
75 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<char volatile>::value
, true);
76 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned char const volatile>::value
, true);
77 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<char const volatile>::value
, true);
79 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned short>::value
, true);
80 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<short>::value
, true);
81 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned short const>::value
, true);
82 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<short const>::value
, true);
83 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned short volatile>::value
, true);
84 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<short volatile>::value
, true);
85 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned short const volatile>::value
, true);
86 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<short const volatile>::value
, true);
88 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned int>::value
, true);
89 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int>::value
, true);
90 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned int const>::value
, true);
91 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int const>::value
, true);
92 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned int volatile>::value
, true);
93 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int volatile>::value
, true);
94 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned int const volatile>::value
, true);
95 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int const volatile>::value
, true);
97 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned long>::value
, true);
98 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long>::value
, true);
99 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned long const>::value
, true);
100 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long const>::value
, true);
101 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned long volatile>::value
, true);
102 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long volatile>::value
, true);
103 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned long const volatile>::value
, true);
104 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long const volatile>::value
, true);
106 #ifdef BOOST_HAS_LONG_LONG
108 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::ulong_long_type
>::value
, true);
109 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::long_long_type
>::value
, true);
110 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::ulong_long_type
const>::value
, true);
111 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::long_long_type
const>::value
, true);
112 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::ulong_long_type
volatile>::value
, true);
113 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::long_long_type
volatile>::value
, true);
114 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::ulong_long_type
const volatile>::value
, true);
115 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
< ::boost::long_long_type
const volatile>::value
, true);
119 #ifdef BOOST_HAS_MS_INT64
121 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int8
>::value
, true);
122 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int8
>::value
, true);
123 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int8
const>::value
, true);
124 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int8
const>::value
, true);
125 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int8
volatile>::value
, true);
126 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int8
volatile>::value
, true);
127 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int8
const volatile>::value
, true);
128 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int8
const volatile>::value
, true);
130 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int16
>::value
, true);
131 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int16
>::value
, true);
132 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int16
const>::value
, true);
133 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int16
const>::value
, true);
134 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int16
volatile>::value
, true);
135 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int16
volatile>::value
, true);
136 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int16
const volatile>::value
, true);
137 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int16
const volatile>::value
, true);
139 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int32
>::value
, true);
140 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int32
>::value
, true);
141 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int32
const>::value
, true);
142 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int32
const>::value
, true);
143 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int32
volatile>::value
, true);
144 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int32
volatile>::value
, true);
145 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int32
const volatile>::value
, true);
146 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int32
const volatile>::value
, true);
148 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int64
>::value
, true);
149 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int64
>::value
, true);
150 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int64
const>::value
, true);
151 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int64
const>::value
, true);
152 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int64
volatile>::value
, true);
153 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int64
volatile>::value
, true);
154 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<unsigned __int64
const volatile>::value
, true);
155 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<__int64
const volatile>::value
, true);
159 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<float>::value
, true);
160 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<float const>::value
, true);
161 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<float volatile>::value
, true);
162 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<float const volatile>::value
, true);
164 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<double>::value
, true);
165 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<double const>::value
, true);
166 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<double volatile>::value
, true);
167 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<double const volatile>::value
, true);
169 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long double>::value
, true);
170 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long double const>::value
, true);
171 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long double volatile>::value
, true);
172 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<long double const volatile>::value
, true);
175 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int>::value
, true);
176 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<void*>::value
, true);
177 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int*const>::value
, true);
178 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<f1
>::value
, true);
179 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<f2
>::value
, true);
180 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<f3
>::value
, true);
181 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<mf1
>::value
, true);
182 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<mf2
>::value
, true);
183 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<mf3
>::value
, true);
184 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<mp
>::value
, true);
185 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<cmf
>::value
, true);
186 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<enum_UDT
>::value
, true);
188 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int&>::value
, false);
189 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
190 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int&&>::value
, false);
192 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<const int&>::value
, false);
193 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int[2]>::value
, true);
194 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int[3][2]>::value
, true);
195 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<int[2][4][5][6][3]>::value
, true);
196 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<UDT
>::value
, false);
197 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<empty_UDT
>::value
, false);
198 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<void>::value
, false);
199 // cases we would like to succeed but can't implement in the language:
200 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<empty_POD_UDT
>::value
, true, false);
201 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<POD_UDT
>::value
, true, false);
202 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<POD_union_UDT
>::value
, true, false);
203 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<empty_POD_union_UDT
>::value
, true, false);
204 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<nothrow_construct_UDT
>::value
, true, false);
205 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<nothrow_assign_UDT
>::value
, false);
206 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<nothrow_copy_UDT
>::value
, false);
208 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<test_abc1
>::value
, false);
209 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<bug11324_derived
>::value
, false);
210 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
211 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<deleted_default_construct
>::value
, false);
213 #if !defined(BOOST_GCC) || (BOOST_GCC >= 40800)
214 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<private_default_construct
>::value
, false);
216 #ifndef BOOST_NO_CXX11_NOEXCEPT
217 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor
<noexcept_default_construct
>::value
, true);