Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / type_traits / test / has_nothrow_constr_test.cpp
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/has_nothrow_constructor.hpp>
13 #endif
14
15 TT_TEST_BEGIN(has_nothrow_constructor)
16
17 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<bool>::value, true);
18 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<bool const>::value, true);
19 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<bool volatile>::value, true);
20 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<bool const volatile>::value, true);
21
22 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<signed char>::value, true);
23 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<signed char const>::value, true);
24 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<signed char volatile>::value, true);
25 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<signed char const volatile>::value, true);
26 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned char>::value, true);
27 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<char>::value, true);
28 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned char const>::value, true);
29 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<char const>::value, true);
30 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned char volatile>::value, true);
31 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<char volatile>::value, true);
32 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned char const volatile>::value, true);
33 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<char const volatile>::value, true);
34
35 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned short>::value, true);
36 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<short>::value, true);
37 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned short const>::value, true);
38 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<short const>::value, true);
39 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned short volatile>::value, true);
40 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<short volatile>::value, true);
41 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned short const volatile>::value, true);
42 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<short const volatile>::value, true);
43
44 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned int>::value, true);
45 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int>::value, true);
46 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned int const>::value, true);
47 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int const>::value, true);
48 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned int volatile>::value, true);
49 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int volatile>::value, true);
50 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned int const volatile>::value, true);
51 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int const volatile>::value, true);
52
53 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned long>::value, true);
54 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long>::value, true);
55 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned long const>::value, true);
56 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long const>::value, true);
57 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned long volatile>::value, true);
58 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long volatile>::value, true);
59 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned long const volatile>::value, true);
60 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long const volatile>::value, true);
61
62 #ifdef BOOST_HAS_LONG_LONG
63
64 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::ulong_long_type>::value, true);
65 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::long_long_type>::value, true);
66 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::ulong_long_type const>::value, true);
67 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::long_long_type const>::value, true);
68 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::ulong_long_type volatile>::value, true);
69 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::long_long_type volatile>::value, true);
70 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::ulong_long_type const volatile>::value, true);
71 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor< ::boost::long_long_type const volatile>::value, true);
72
73 #endif
74
75 #ifdef BOOST_HAS_MS_INT64
76
77 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int8>::value, true);
78 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int8>::value, true);
79 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int8 const>::value, true);
80 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int8 const>::value, true);
81 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int8 volatile>::value, true);
82 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int8 volatile>::value, true);
83 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int8 const volatile>::value, true);
84 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int8 const volatile>::value, true);
85
86 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int16>::value, true);
87 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int16>::value, true);
88 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int16 const>::value, true);
89 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int16 const>::value, true);
90 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int16 volatile>::value, true);
91 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int16 volatile>::value, true);
92 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int16 const volatile>::value, true);
93 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int16 const volatile>::value, true);
94
95 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int32>::value, true);
96 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int32>::value, true);
97 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int32 const>::value, true);
98 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int32 const>::value, true);
99 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int32 volatile>::value, true);
100 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int32 volatile>::value, true);
101 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int32 const volatile>::value, true);
102 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int32 const volatile>::value, true);
103
104 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int64>::value, true);
105 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int64>::value, true);
106 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int64 const>::value, true);
107 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int64 const>::value, true);
108 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int64 volatile>::value, true);
109 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int64 volatile>::value, true);
110 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<unsigned __int64 const volatile>::value, true);
111 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<__int64 const volatile>::value, true);
112
113 #endif
114
115 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<float>::value, true);
116 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<float const>::value, true);
117 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<float volatile>::value, true);
118 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<float const volatile>::value, true);
119
120 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<double>::value, true);
121 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<double const>::value, true);
122 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<double volatile>::value, true);
123 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<double const volatile>::value, true);
124
125 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long double>::value, true);
126 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long double const>::value, true);
127 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long double volatile>::value, true);
128 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<long double const volatile>::value, true);
129
130
131 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int>::value, true);
132 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<void*>::value, true);
133 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int*const>::value, true);
134 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<f1>::value, true);
135 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<f2>::value, true);
136 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<f3>::value, true);
137 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<mf1>::value, true);
138 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<mf2>::value, true);
139 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<mf3>::value, true);
140 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<mp>::value, true);
141 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<cmf>::value, true);
142 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<enum_UDT>::value, true);
143
144 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int&>::value, false);
145 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
146 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int&&>::value, false);
147 #endif
148 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<const int&>::value, false);
149 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int[2]>::value, true);
150 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int[3][2]>::value, true);
151 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<int[2][4][5][6][3]>::value, true);
152 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<UDT>::value, false);
153 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<empty_UDT>::value, false);
154 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<void>::value, false);
155 // cases we would like to succeed but can't implement in the language:
156 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<empty_POD_UDT>::value, true, false);
157 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<POD_UDT>::value, true, false);
158 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<POD_union_UDT>::value, true, false);
159 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<empty_POD_union_UDT>::value, true, false);
160 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<nothrow_construct_UDT>::value, true, false);
161 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<nothrow_assign_UDT>::value, false);
162 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<nothrow_copy_UDT>::value, false);
163
164 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_constructor<test_abc1>::value, false);
165
166 TT_TEST_END
167
168
169