]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/is_assignable_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / type_traits / test / is_assignable_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/is_assignable.hpp>
13 #endif
14
15 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
16
17 struct non_assignable
18 {
19 non_assignable();
20 non_assignable& operator=(const non_assignable&) = delete;
21 };
22
23 #endif
24
25 #ifndef BOOST_NO_CXX11_NOEXCEPT
26
27 struct noexcept_assignable
28 {
29 noexcept_assignable();
30 noexcept_assignable& operator=(const non_assignable&)noexcept;
31 };
32
33 #endif
34
35 TT_TEST_BEGIN(is_assignable)
36
37 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<bool&, const bool&>::value), true);
38 #ifndef TEST_STD
39 // unspecified behaviour:
40 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<bool const&>::value), false);
41 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<bool volatile&, bool const volatile&>::value), true);
42 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<bool const volatile&>::value), false);
43 #endif
44
45 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<signed char&, const signed char&>::value), true);
46 #ifndef TEST_STD
47 // unspecified behaviour:
48 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<signed char const&>::value), false);
49 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<signed char volatile&, const signed char volatile&>::value), true);
50 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<signed char const volatile&>::value), false);
51 #endif
52 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned char&, const unsigned char&>::value), true);
53 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<char&, const char&>::value), true);
54
55 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned short&, const unsigned short&>::value), true);
56 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<short&, const short&>::value), true);
57
58 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned int&, const unsigned int&>::value), true);
59 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int&, const int&>::value), true);
60 #ifndef TEST_STD
61 // unspecified behaviour:
62 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned int const&>::value), false);
63 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int const&>::value), false);
64 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned int volatile&>::value), true);
65 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int volatile&>::value), true);
66 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned int const volatile&>::value), false);
67 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int const volatile&>::value), false);
68 #endif
69
70 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned long&, const unsigned long&>::value), true);
71 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long&, const long&>::value), true);
72 #ifndef TEST_STD
73 // unspecified behaviour:
74 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned long const&>::value), false);
75 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long const&>::value), false);
76 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned long volatile&>::value), true);
77 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long volatile&>::value), true);
78 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<unsigned long const volatile&>::value), false);
79 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long const volatile&>::value), false);
80 #endif
81
82 #ifdef BOOST_HAS_LONG_LONG
83
84 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::ulong_long_type&>::value), true);
85 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::long_long_type&>::value), true);
86 #ifndef TEST_STD
87 // unspecified behaviour:
88 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::ulong_long_type const&>::value), false);
89 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::long_long_type const&>::value), false);
90 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::ulong_long_type volatile&>::value), true);
91 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::long_long_type volatile&>::value), true);
92 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::ulong_long_type const volatile&>::value), false);
93 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable< ::boost::long_long_type const volatile&>::value), false);
94 #endif
95 #endif
96
97 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<float&, const float&>::value), true);
98 #ifndef TEST_STD
99 // unspecified behaviour:
100 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<float const&>::value), false);
101 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<float volatile&>::value), true);
102 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<float const volatile&>::value), false);
103 #endif
104
105 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<double&, const double&>::value), true);
106 #ifndef TEST_STD
107 // unspecified behaviour:
108 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<double const&>::value), false);
109 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<double volatile&>::value), true);
110 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<double const volatile&>::value), false);
111 #endif
112
113 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long double&, const long double&>::value), true);
114 #ifndef TEST_STD
115 // unspecified behaviour:
116 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long double const&>::value), false);
117 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long double volatile&>::value), true);
118 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<long double const volatile&>::value), false);
119 #endif
120
121 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<void*&>::value), true);
122 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
123 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int&, int&&>::value), true);
124 #endif
125 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<const int&>::value), false);
126 //BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int(&)[2], const int(&)[2]>::value), true);
127 //BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int(&)[3][2]>::value), true);
128 //BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<int(&)[2][4][5][6][3]>::value), true);
129 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<UDT&>::value), true, false);
130 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<empty_UDT&>::value), true, false);
131 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<void>::value), false);
132 // cases we would like to succeed but can't implement in the language:
133 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<empty_POD_UDT&>::value), true, false);
134 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<POD_UDT&>::value), true, false);
135 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<POD_union_UDT&>::value), true, false);
136 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<empty_POD_union_UDT&>::value), true, false);
137 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<nothrow_assign_UDT&>::value), true, false);
138
139 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable<test_abc1&>::value), true, false);
140
141 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
142 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<non_assignable&>::value), false);
143 #endif
144 #ifndef BOOST_NO_CXX11_NOEXCEPT
145 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable<noexcept_assignable&>::value), true);
146 #endif
147
148 TT_TEST_END
149
150
151