]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/is_assignable_test.cpp
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/is_assignable.hpp>
13 #include "check_integral_constant.hpp"
15 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
20 non_assignable
& operator=(const non_assignable
&) = delete;
25 #ifndef BOOST_NO_CXX11_NOEXCEPT
27 struct noexcept_assignable
29 noexcept_assignable();
30 noexcept_assignable
& operator=(const noexcept_assignable
&)noexcept
;
35 TT_TEST_BEGIN(is_assignable
)
37 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable
<bool&, const bool&>::value
), true);
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);
45 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable
<signed char&, const signed char&>::value
), true);
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);
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);
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);
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);
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);
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);
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);
82 #ifdef BOOST_HAS_LONG_LONG
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);
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);
97 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable
<float&, const float&>::value
), true);
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);
105 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable
<double&, const double&>::value
), true);
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);
113 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable
<long double&, const long double&>::value
), true);
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);
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);
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);
139 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_assignable
<test_abc1
&>::value
), true, false);
141 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
142 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable
<non_assignable
&>::value
), false);
144 #ifndef BOOST_NO_CXX11_NOEXCEPT
145 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_assignable
<noexcept_assignable
&>::value
), true);