]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/is_trivially_assignable/value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / is_trivially_assignable / value.cc
1 // { dg-do compile { target c++11 } }
2 //
3 // 2014-10-09 Ville Voutilainen <ville.voutilainen@gmail.com>
4 //
5 // Copyright (C) 2014-2019 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
21
22 #include <type_traits>
23 #include <testsuite_tr1.h>
24
25 struct HasTemplateCAssign
26 {
27 HasTemplateCAssign& operator=(const HasTemplateCAssign&) = default;
28 template <class T>
29 HasTemplateCAssign& operator=(T&&);
30 };
31
32 struct MoveOnly
33 {
34 MoveOnly& operator=(MoveOnly&&) = default;
35 };
36
37 struct MoveOnly2
38 {
39 MoveOnly2& operator=(MoveOnly2&&) = delete;
40 };
41
42 void test01()
43 {
44 using std::is_trivially_assignable;
45 using namespace __gnu_test;
46
47 static_assert(test_property<is_trivially_assignable,
48 int, int>(false), "");
49 static_assert(test_property<is_trivially_assignable,
50 int&, int>(true), "");
51 static_assert(test_property<is_trivially_assignable,
52 int&, int&>(true), "");
53 static_assert(test_property<is_trivially_assignable,
54 int&, int&&>(true), "");
55 static_assert(test_property<is_trivially_assignable,
56 int&, const int&>(true), "");
57 static_assert(test_property<is_trivially_assignable,
58 int&, int*>(false), "");
59 static_assert(test_property<is_trivially_assignable,
60 int&, void*>(false), "");
61 static_assert(test_property<is_trivially_assignable,
62 const int, int>(false), "");
63 static_assert(test_property<is_trivially_assignable,
64 const int&, int>(false), "");
65 static_assert(test_property<is_trivially_assignable,
66 const int&, const int&>(false), "");
67 static_assert(test_property<is_trivially_assignable,
68 const int*&, int*>(true), "");
69 static_assert(test_property<is_trivially_assignable,
70 int*&, const int*&>(false), "");
71 static_assert(test_property<is_trivially_assignable,
72 int*&, const int&>(false), "");
73 static_assert(test_property<is_trivially_assignable,
74 const int*&, void*>(false), "");
75 static_assert(test_property<is_trivially_assignable,
76 const void*&, void*>(true), "");
77 static_assert(test_property<is_trivially_assignable,
78 const void*&, int*>(true), "");
79
80 static_assert(test_property<is_trivially_assignable,
81 TType, TType>(true), "");
82 static_assert(test_property<is_trivially_assignable,
83 TType&, TType>(true), "");
84 static_assert(test_property<is_trivially_assignable,
85 TType&, TType&>(true), "");
86 static_assert(test_property<is_trivially_assignable,
87 TType&, TType&&>(true), "");
88 static_assert(test_property<is_trivially_assignable,
89 TType&, const TType&>(true), "");
90 static_assert(test_property<is_trivially_assignable,
91 PODType, PODType>(true), "");
92 static_assert(test_property<is_trivially_assignable,
93 NType&, NType&>(false), "");
94 static_assert(test_property<is_trivially_assignable,
95 SLType, SLType>(true), "");
96 static_assert(test_property<is_trivially_assignable,
97 assign::Empty, assign::Empty>(true), "");
98 static_assert(test_property<is_trivially_assignable,
99 assign::Abstract, assign::Abstract>(false), "");
100 static_assert(test_property<is_trivially_assignable,
101 assign::Ellipsis, assign::Ellipsis>(true), "");
102 static_assert(test_property<is_trivially_assignable,
103 assign::DelEllipsis, assign::DelEllipsis>(true), "");
104 static_assert(test_property<is_trivially_assignable,
105 assign::Any, assign::Any>(true), "");
106 static_assert(test_property<is_trivially_assignable,
107 assign::DelDef, assign::DelDef>(true), "");
108 static_assert(test_property<is_trivially_assignable,
109 assign::DelCopy, assign::DelCopy>(true), "");
110 static_assert(test_property<is_trivially_assignable,
111 assign::Nontrivial, assign::Nontrivial>(false), "");
112 static_assert(test_property<is_trivially_assignable,
113 assign::AnyAssign, assign::AnyAssign>(true), "");
114 static_assert(test_property<is_trivially_assignable,
115 assign::DelAnyAssign, assign::DelAnyAssign>(true), "");
116 static_assert(test_property<is_trivially_assignable,
117 assign::DelCopyAssign, assign::DelCopyAssign>(true), "");
118 static_assert(test_property<is_trivially_assignable,
119 assign::MO, assign::MO>(true), "");
120 static_assert(test_property<is_trivially_assignable,
121 assign::MO, assign::MO&&>(true), "");
122 static_assert(test_property<is_trivially_assignable,
123 assign::MO, assign::MO&>(false), "");
124 static_assert(test_property<is_trivially_assignable,
125 assign::MO, const assign::MO&>(false), "");
126 static_assert(test_property<is_trivially_assignable,
127 CopyConsOnlyType, CopyConsOnlyType>(false), "");
128 static_assert(test_property<is_trivially_assignable,
129 CopyConsOnlyType, const CopyConsOnlyType&>(false), "");
130 static_assert(test_property<is_trivially_assignable,
131 MoveConsOnlyType, MoveConsOnlyType>(false), "");
132 static_assert(test_property<is_trivially_assignable,
133 MoveConsOnlyType, MoveConsOnlyType&&>(false), "");
134 static_assert(test_property<is_trivially_assignable,
135 HasTemplateCAssign, HasTemplateCAssign>(false), "");
136 static_assert(test_property<is_trivially_assignable,
137 HasTemplateCAssign, const HasTemplateCAssign&>(true), "");
138 static_assert(test_property<is_trivially_assignable,
139 ClassType, DerivedType>(true), "");
140 static_assert(test_property<is_trivially_assignable,
141 ClassType, DerivedType&>(true), "");
142 static_assert(test_property<is_trivially_assignable,
143 ClassType, DerivedType&&>(true), "");
144 static_assert(test_property<is_trivially_assignable,
145 ClassType, const DerivedType&>(true), "");
146 static_assert(test_property<is_trivially_assignable,
147 MoveOnly, MoveOnly>(true), "");
148 static_assert(test_property<is_trivially_assignable,
149 MoveOnly, MoveOnly&&>(true), "");
150 static_assert(test_property<is_trivially_assignable,
151 MoveOnly, MoveOnly&>(false), "");
152 static_assert(test_property<is_trivially_assignable,
153 MoveOnly, const MoveOnly&>(false), "");
154 static_assert(test_property<is_trivially_assignable,
155 MoveOnly2, MoveOnly2>(false), "");
156 }