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 <type_traits>
10 # include <boost/type_traits/has_nothrow_assign.hpp>
13 #include "check_integral_constant.hpp"
15 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
19 BOOST_TT_PROC
non_assignable();
20 BOOST_TT_PROC non_assignable
& operator=(const non_assignable
&) = delete;
25 #ifndef BOOST_NO_CXX11_NOEXCEPT
27 struct noexcept_assignable
29 BOOST_TT_PROC
noexcept_assignable();
30 BOOST_TT_PROC noexcept_assignable
& operator=(const noexcept_assignable
&)noexcept
;
35 TT_TEST_BEGIN(has_nothrow_assign
)
37 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<bool>::value
, true);
39 // unspecified behaviour:
40 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<bool const>::value
, false);
41 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<bool volatile>::value
, false);
42 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<bool const volatile>::value
, false);
45 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<signed char>::value
, true);
47 // unspecified behaviour:
48 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<signed char const>::value
, false);
49 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<signed char volatile>::value
, false);
50 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<signed char const volatile>::value
, false);
52 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned char>::value
, true);
53 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<char>::value
, true);
55 // unspecified behaviour:
56 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned char const>::value
, false);
57 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<char const>::value
, false);
58 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned char volatile>::value
, false);
59 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<char volatile>::value
, false);
60 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned char const volatile>::value
, false);
61 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<char const volatile>::value
, false);
64 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned short>::value
, true);
65 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<short>::value
, true);
67 // unspecified behaviour:
68 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned short const>::value
, false);
69 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<short const>::value
, false);
70 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned short volatile>::value
, false);
71 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<short volatile>::value
, false);
72 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned short const volatile>::value
, false);
73 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<short const volatile>::value
, false);
76 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned int>::value
, true);
77 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int>::value
, true);
79 // unspecified behaviour:
80 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned int const>::value
, false);
81 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int const>::value
, false);
82 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned int volatile>::value
, false);
83 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int volatile>::value
, false);
84 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned int const volatile>::value
, false);
85 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int const volatile>::value
, false);
88 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned long>::value
, true);
89 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long>::value
, true);
91 // unspecified behaviour:
92 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned long const>::value
, false);
93 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long const>::value
, false);
94 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned long volatile>::value
, false);
95 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long volatile>::value
, false);
96 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned long const volatile>::value
, false);
97 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long const volatile>::value
, false);
100 #ifdef BOOST_HAS_LONG_LONG
102 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::ulong_long_type
>::value
, true);
103 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::long_long_type
>::value
, true);
105 // unspecified behaviour:
106 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::ulong_long_type
const>::value
, false);
107 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::long_long_type
const>::value
, false);
108 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::ulong_long_type
volatile>::value
, false);
109 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::long_long_type
volatile>::value
, false);
110 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::ulong_long_type
const volatile>::value
, false);
111 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
< ::boost::long_long_type
const volatile>::value
, false);
115 #ifdef BOOST_HAS_MS_INT64
117 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int8
>::value
, true);
118 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int8
>::value
, true);
120 // unspecified behaviour:
121 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int8
const>::value
, false);
122 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int8
const>::value
, false);
123 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int8
volatile>::value
, false);
124 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int8
volatile>::value
, false);
125 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int8
const volatile>::value
, false);
126 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int8
const volatile>::value
, false);
129 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int16
>::value
, true);
130 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int16
>::value
, true);
132 // unspecified behaviour:
133 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int16
const>::value
, false);
134 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int16
const>::value
, false);
135 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int16
volatile>::value
, false);
136 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int16
volatile>::value
, false);
137 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int16
const volatile>::value
, false);
138 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int16
const volatile>::value
, false);
141 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int32
>::value
, true);
142 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int32
>::value
, true);
144 // unspecified behaviour:
145 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int32
const>::value
, false);
146 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int32
const>::value
, false);
147 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int32
volatile>::value
, false);
148 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int32
volatile>::value
, false);
149 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int32
const volatile>::value
, false);
150 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int32
const volatile>::value
, false);
153 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int64
>::value
, true);
154 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int64
>::value
, true);
156 // unspecified behaviour:
157 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int64
const>::value
, false);
158 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int64
const>::value
, false);
159 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int64
volatile>::value
, false);
160 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int64
volatile>::value
, false);
161 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<unsigned __int64
const volatile>::value
, false);
162 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<__int64
const volatile>::value
, false);
166 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<float>::value
, true);
168 // unspecified behaviour:
169 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<float const>::value
, false);
170 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<float volatile>::value
, false);
171 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<float const volatile>::value
, false);
174 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<double>::value
, true);
176 // unspecified behaviour:
177 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<double const>::value
, false);
178 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<double volatile>::value
, false);
179 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<double const volatile>::value
, false);
182 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long double>::value
, true);
184 // unspecified behaviour:
185 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long double const>::value
, false);
186 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long double volatile>::value
, false);
187 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<long double const volatile>::value
, false);
190 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int>::value
, true);
191 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<void*>::value
, true);
193 // unspecified behaviour:
194 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int*const>::value
, false);
196 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<f1
>::value
, true);
197 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<f2
>::value
, true);
198 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<f3
>::value
, true);
199 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<mf1
>::value
, true);
200 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<mf2
>::value
, true);
201 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<mf3
>::value
, true);
202 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<mp
>::value
, true);
203 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<cmf
>::value
, true);
204 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<enum_UDT
>::value
, true);
206 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int&>::value
, false);
207 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
208 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int&&>::value
, false);
210 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<const int&>::value
, false);
211 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int[2]>::value
, true);
212 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int[3][2]>::value
, true);
213 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<int[2][4][5][6][3]>::value
, true);
214 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<UDT
>::value
, false);
215 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<empty_UDT
>::value
, false);
216 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<void>::value
, false);
217 // cases we would like to succeed but can't implement in the language:
218 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<empty_POD_UDT
>::value
, true, false);
219 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<POD_UDT
>::value
, true, false);
220 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<POD_union_UDT
>::value
, true, false);
221 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<empty_POD_union_UDT
>::value
, true, false);
222 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<nothrow_assign_UDT
>::value
, true, false);
223 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<nothrow_copy_UDT
>::value
, false);
224 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<nothrow_construct_UDT
>::value
, false);
226 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<test_abc1
>::value
, false);
228 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
229 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<non_assignable
>::value
, false);
231 #ifndef BOOST_NO_CXX11_NOEXCEPT
232 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_nothrow_assign
<noexcept_assignable
>::value
, true);