]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/type_traits/test/is_default_constr_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / type_traits / test / is_default_constr_test.cpp
CommitLineData
7c673cae
FG
1
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)
6
7#include "test.hpp"
8#include "check_integral_constant.hpp"
9#ifdef TEST_STD
10# include <type_traits>
11#else
12# include <boost/type_traits/is_default_constructible.hpp>
13#endif
14
15class bug11324_base
16{
17public:
18 bug11324_base & operator=(const bug11324_base&){ throw int(); }
19 virtual ~bug11324_base() {}
20};
21
22class bug11324_derived : public bug11324_base
23{
24public:
25 char data;
26 explicit bug11324_derived(char arg) : data(arg) {}
27};
28
29#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
30
31struct deleted_default_construct
32{
33 deleted_default_construct() = delete;
34 deleted_default_construct(char val) : member(val) {}
35 char member;
36};
37
38#endif
39
40struct private_default_construct
41{
42private:
43 private_default_construct();
44public:
45 private_default_construct(char val) : member(val) {}
46 char member;
47};
48
49TT_TEST_BEGIN(is_default_constructible)
50
51BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<bool>::value, true);
52BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<bool const>::value, true);
53BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<bool volatile>::value, true);
54BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<bool const volatile>::value, true);
55
56BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<signed char>::value, true);
57BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<signed char const>::value, true);
58BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<signed char volatile>::value, true);
59BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<signed char const volatile>::value, true);
60BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned char>::value, true);
61BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<char>::value, true);
62BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned char const>::value, true);
63BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<char const>::value, true);
64BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned char volatile>::value, true);
65BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<char volatile>::value, true);
66BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned char const volatile>::value, true);
67BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<char const volatile>::value, true);
68
69BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned short>::value, true);
70BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<short>::value, true);
71BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned short const>::value, true);
72BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<short const>::value, true);
73BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned short volatile>::value, true);
74BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<short volatile>::value, true);
75BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned short const volatile>::value, true);
76BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<short const volatile>::value, true);
77
78BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned int>::value, true);
79BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int>::value, true);
80BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned int const>::value, true);
81BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int const>::value, true);
82BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned int volatile>::value, true);
83BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int volatile>::value, true);
84BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned int const volatile>::value, true);
85BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int const volatile>::value, true);
86
87BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned long>::value, true);
88BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long>::value, true);
89BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned long const>::value, true);
90BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long const>::value, true);
91BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned long volatile>::value, true);
92BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long volatile>::value, true);
93BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned long const volatile>::value, true);
94BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long const volatile>::value, true);
95
96#ifdef BOOST_HAS_LONG_LONG
97
98BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::ulong_long_type>::value, true);
99BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::long_long_type>::value, true);
100BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::ulong_long_type const>::value, true);
101BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::long_long_type const>::value, true);
102BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::ulong_long_type volatile>::value, true);
103BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::long_long_type volatile>::value, true);
104BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::ulong_long_type const volatile>::value, true);
105BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible< ::boost::long_long_type const volatile>::value, true);
106
107#endif
108
109#ifdef BOOST_HAS_MS_INT64
110
111BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int8>::value, true);
112BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int8>::value, true);
113BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int8 const>::value, true);
114BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int8 const>::value, true);
115BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int8 volatile>::value, true);
116BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int8 volatile>::value, true);
117BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int8 const volatile>::value, true);
118BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int8 const volatile>::value, true);
119
120BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int16>::value, true);
121BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int16>::value, true);
122BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int16 const>::value, true);
123BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int16 const>::value, true);
124BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int16 volatile>::value, true);
125BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int16 volatile>::value, true);
126BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int16 const volatile>::value, true);
127BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int16 const volatile>::value, true);
128
129BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int32>::value, true);
130BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int32>::value, true);
131BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int32 const>::value, true);
132BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int32 const>::value, true);
133BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int32 volatile>::value, true);
134BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int32 volatile>::value, true);
135BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int32 const volatile>::value, true);
136BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int32 const volatile>::value, true);
137
138BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int64>::value, true);
139BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int64>::value, true);
140BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int64 const>::value, true);
141BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int64 const>::value, true);
142BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int64 volatile>::value, true);
143BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int64 volatile>::value, true);
144BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<unsigned __int64 const volatile>::value, true);
145BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<__int64 const volatile>::value, true);
146
147#endif
148
149BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<float>::value, true);
150BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<float const>::value, true);
151BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<float volatile>::value, true);
152BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<float const volatile>::value, true);
153
154BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<double>::value, true);
155BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<double const>::value, true);
156BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<double volatile>::value, true);
157BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<double const volatile>::value, true);
158
159BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long double>::value, true);
160BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long double const>::value, true);
161BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long double volatile>::value, true);
162BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<long double const volatile>::value, true);
163
164
165BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int>::value, true);
166BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<void*>::value, true);
167BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int*const>::value, true);
168BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<f1>::value, true);
169BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<f2>::value, true);
170BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<f3>::value, true);
171BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<mf1>::value, true);
172BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<mf2>::value, true);
173BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<mf3>::value, true);
174BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<mp>::value, true);
175BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<cmf>::value, true);
176BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<enum_UDT>::value, true);
177
178BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int&>::value, false);
179#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
180BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int&&>::value, false);
181#endif
182BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<const int&>::value, false);
183BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int[2]>::value, true);
184BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int[3][2]>::value, true);
185BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<int[2][4][5][6][3]>::value, true);
186BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible<UDT>::value, true, false);
187BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible<empty_UDT>::value, true, false);
188BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<void>::value, false);
189// cases we would like to succeed but can't implement in the language:
190BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible<empty_POD_UDT>::value, true, false);
191BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible<POD_UDT>::value, true, false);
192BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible<POD_union_UDT>::value, true, false);
193BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible<empty_POD_union_UDT>::value, true, false);
194BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_default_constructible<nothrow_construct_UDT>::value, true, false);
195
196BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<test_abc1>::value, false);
197BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<bug11324_derived>::value, false);
198#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
199BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<deleted_default_construct>::value, false);
200#endif
b32b8144 201#if !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800)
7c673cae
FG
202BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_default_constructible<private_default_construct>::value, false);
203#endif
204
205TT_TEST_END
206