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/is_default_constructible.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 TT_TEST_BEGIN(is_default_constructible
)
51 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<bool>::value
, true);
52 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<bool const>::value
, true);
53 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<bool volatile>::value
, true);
54 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<bool const volatile>::value
, true);
56 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<signed char>::value
, true);
57 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<signed char const>::value
, true);
58 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<signed char volatile>::value
, true);
59 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<signed char const volatile>::value
, true);
60 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned char>::value
, true);
61 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<char>::value
, true);
62 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned char const>::value
, true);
63 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<char const>::value
, true);
64 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned char volatile>::value
, true);
65 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<char volatile>::value
, true);
66 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned char const volatile>::value
, true);
67 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<char const volatile>::value
, true);
69 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned short>::value
, true);
70 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<short>::value
, true);
71 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned short const>::value
, true);
72 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<short const>::value
, true);
73 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned short volatile>::value
, true);
74 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<short volatile>::value
, true);
75 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned short const volatile>::value
, true);
76 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<short const volatile>::value
, true);
78 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned int>::value
, true);
79 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int>::value
, true);
80 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned int const>::value
, true);
81 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int const>::value
, true);
82 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned int volatile>::value
, true);
83 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int volatile>::value
, true);
84 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned int const volatile>::value
, true);
85 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int const volatile>::value
, true);
87 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned long>::value
, true);
88 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long>::value
, true);
89 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned long const>::value
, true);
90 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long const>::value
, true);
91 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned long volatile>::value
, true);
92 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long volatile>::value
, true);
93 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned long const volatile>::value
, true);
94 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long const volatile>::value
, true);
96 #ifdef BOOST_HAS_LONG_LONG
98 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::ulong_long_type
>::value
, true);
99 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::long_long_type
>::value
, true);
100 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::ulong_long_type
const>::value
, true);
101 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::long_long_type
const>::value
, true);
102 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::ulong_long_type
volatile>::value
, true);
103 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::long_long_type
volatile>::value
, true);
104 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::ulong_long_type
const volatile>::value
, true);
105 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
< ::boost::long_long_type
const volatile>::value
, true);
109 #ifdef BOOST_HAS_MS_INT64
111 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int8
>::value
, true);
112 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int8
>::value
, true);
113 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int8
const>::value
, true);
114 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int8
const>::value
, true);
115 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int8
volatile>::value
, true);
116 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int8
volatile>::value
, true);
117 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int8
const volatile>::value
, true);
118 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int8
const volatile>::value
, true);
120 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int16
>::value
, true);
121 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int16
>::value
, true);
122 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int16
const>::value
, true);
123 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int16
const>::value
, true);
124 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int16
volatile>::value
, true);
125 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int16
volatile>::value
, true);
126 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int16
const volatile>::value
, true);
127 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int16
const volatile>::value
, true);
129 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int32
>::value
, true);
130 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int32
>::value
, true);
131 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int32
const>::value
, true);
132 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int32
const>::value
, true);
133 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int32
volatile>::value
, true);
134 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int32
volatile>::value
, true);
135 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int32
const volatile>::value
, true);
136 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int32
const volatile>::value
, true);
138 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int64
>::value
, true);
139 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int64
>::value
, true);
140 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int64
const>::value
, true);
141 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int64
const>::value
, true);
142 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int64
volatile>::value
, true);
143 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int64
volatile>::value
, true);
144 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<unsigned __int64
const volatile>::value
, true);
145 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<__int64
const volatile>::value
, true);
149 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<float>::value
, true);
150 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<float const>::value
, true);
151 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<float volatile>::value
, true);
152 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<float const volatile>::value
, true);
154 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<double>::value
, true);
155 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<double const>::value
, true);
156 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<double volatile>::value
, true);
157 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<double const volatile>::value
, true);
159 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long double>::value
, true);
160 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long double const>::value
, true);
161 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long double volatile>::value
, true);
162 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<long double const volatile>::value
, true);
165 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int>::value
, true);
166 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<void*>::value
, true);
167 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int*const>::value
, true);
168 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<f1
>::value
, true);
169 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<f2
>::value
, true);
170 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<f3
>::value
, true);
171 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<mf1
>::value
, true);
172 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<mf2
>::value
, true);
173 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<mf3
>::value
, true);
174 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<mp
>::value
, true);
175 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<cmf
>::value
, true);
176 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<enum_UDT
>::value
, true);
178 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int&>::value
, false);
179 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
180 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int&&>::value
, false);
182 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<const int&>::value
, false);
183 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int[2]>::value
, true);
184 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int[3][2]>::value
, true);
185 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<int[2][4][5][6][3]>::value
, true);
186 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible
<UDT
>::value
, true, false);
187 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible
<empty_UDT
>::value
, true, false);
188 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<void>::value
, false);
189 // cases we would like to succeed but can't implement in the language:
190 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible
<empty_POD_UDT
>::value
, true, false);
191 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible
<POD_UDT
>::value
, true, false);
192 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible
<POD_union_UDT
>::value
, true, false);
193 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible
<empty_POD_union_UDT
>::value
, true, false);
194 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible
<nothrow_construct_UDT
>::value
, true, false);
196 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<test_abc1
>::value
, false);
197 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<bug11324_derived
>::value
, false);
198 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
199 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<deleted_default_construct
>::value
, false);
201 #if !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40700)
202 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible
<private_default_construct
>::value
, false);