source: Daodan/MSYS2/mingw32/include/c++/11.2.0/bits/enable_special_members.h@ 1181

Last change on this file since 1181 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 12.1 KB
Line 
1// <bits/enable_special_members.h> -*- C++ -*-
2
3// Copyright (C) 2013-2021 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file bits/enable_special_members.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly.
28 */
29
30#ifndef _ENABLE_SPECIAL_MEMBERS_H
31#define _ENABLE_SPECIAL_MEMBERS_H 1
32
33#pragma GCC system_header
34
35#include <bits/c++config.h>
36
37namespace std _GLIBCXX_VISIBILITY(default)
38{
39_GLIBCXX_BEGIN_NAMESPACE_VERSION
40
41 struct _Enable_default_constructor_tag
42 {
43 explicit constexpr _Enable_default_constructor_tag() = default;
44 };
45
46/**
47 * @brief A mixin helper to conditionally enable or disable the default
48 * constructor.
49 * @sa _Enable_special_members
50 */
51template<bool _Switch, typename _Tag = void>
52 struct _Enable_default_constructor
53 {
54 constexpr _Enable_default_constructor() noexcept = default;
55 constexpr _Enable_default_constructor(_Enable_default_constructor const&)
56 noexcept = default;
57 constexpr _Enable_default_constructor(_Enable_default_constructor&&)
58 noexcept = default;
59 _Enable_default_constructor&
60 operator=(_Enable_default_constructor const&) noexcept = default;
61 _Enable_default_constructor&
62 operator=(_Enable_default_constructor&&) noexcept = default;
63
64 // Can be used in other ctors.
65 constexpr explicit
66 _Enable_default_constructor(_Enable_default_constructor_tag) { }
67 };
68
69
70/**
71 * @brief A mixin helper to conditionally enable or disable the default
72 * destructor.
73 * @sa _Enable_special_members
74 */
75template<bool _Switch, typename _Tag = void>
76 struct _Enable_destructor { };
77
78/**
79 * @brief A mixin helper to conditionally enable or disable the copy/move
80 * special members.
81 * @sa _Enable_special_members
82 */
83template<bool _Copy, bool _CopyAssignment,
84 bool _Move, bool _MoveAssignment,
85 typename _Tag = void>
86 struct _Enable_copy_move { };
87
88/**
89 * @brief A mixin helper to conditionally enable or disable the special
90 * members.
91 *
92 * The @c _Tag type parameter is to make mixin bases unique and thus avoid
93 * ambiguities.
94 */
95template<bool _Default, bool _Destructor,
96 bool _Copy, bool _CopyAssignment,
97 bool _Move, bool _MoveAssignment,
98 typename _Tag = void>
99 struct _Enable_special_members
100 : private _Enable_default_constructor<_Default, _Tag>,
101 private _Enable_destructor<_Destructor, _Tag>,
102 private _Enable_copy_move<_Copy, _CopyAssignment,
103 _Move, _MoveAssignment,
104 _Tag>
105 { };
106
107// Boilerplate follows.
108
109template<typename _Tag>
110 struct _Enable_default_constructor<false, _Tag>
111 {
112 constexpr _Enable_default_constructor() noexcept = delete;
113 constexpr _Enable_default_constructor(_Enable_default_constructor const&)
114 noexcept = default;
115 constexpr _Enable_default_constructor(_Enable_default_constructor&&)
116 noexcept = default;
117 _Enable_default_constructor&
118 operator=(_Enable_default_constructor const&) noexcept = default;
119 _Enable_default_constructor&
120 operator=(_Enable_default_constructor&&) noexcept = default;
121
122 // Can be used in other ctors.
123 constexpr explicit
124 _Enable_default_constructor(_Enable_default_constructor_tag) { }
125 };
126
127template<typename _Tag>
128 struct _Enable_destructor<false, _Tag>
129 { ~_Enable_destructor() noexcept = delete; };
130
131template<typename _Tag>
132 struct _Enable_copy_move<false, true, true, true, _Tag>
133 {
134 constexpr _Enable_copy_move() noexcept = default;
135 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
136 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
137 _Enable_copy_move&
138 operator=(_Enable_copy_move const&) noexcept = default;
139 _Enable_copy_move&
140 operator=(_Enable_copy_move&&) noexcept = default;
141 };
142
143template<typename _Tag>
144 struct _Enable_copy_move<true, false, true, true, _Tag>
145 {
146 constexpr _Enable_copy_move() noexcept = default;
147 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
148 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
149 _Enable_copy_move&
150 operator=(_Enable_copy_move const&) noexcept = delete;
151 _Enable_copy_move&
152 operator=(_Enable_copy_move&&) noexcept = default;
153 };
154
155template<typename _Tag>
156 struct _Enable_copy_move<false, false, true, true, _Tag>
157 {
158 constexpr _Enable_copy_move() noexcept = default;
159 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
160 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
161 _Enable_copy_move&
162 operator=(_Enable_copy_move const&) noexcept = delete;
163 _Enable_copy_move&
164 operator=(_Enable_copy_move&&) noexcept = default;
165 };
166
167template<typename _Tag>
168 struct _Enable_copy_move<true, true, false, true, _Tag>
169 {
170 constexpr _Enable_copy_move() noexcept = default;
171 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
172 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
173 _Enable_copy_move&
174 operator=(_Enable_copy_move const&) noexcept = default;
175 _Enable_copy_move&
176 operator=(_Enable_copy_move&&) noexcept = default;
177 };
178
179template<typename _Tag>
180 struct _Enable_copy_move<false, true, false, true, _Tag>
181 {
182 constexpr _Enable_copy_move() noexcept = default;
183 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
184 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
185 _Enable_copy_move&
186 operator=(_Enable_copy_move const&) noexcept = default;
187 _Enable_copy_move&
188 operator=(_Enable_copy_move&&) noexcept = default;
189 };
190
191template<typename _Tag>
192 struct _Enable_copy_move<true, false, false, true, _Tag>
193 {
194 constexpr _Enable_copy_move() noexcept = default;
195 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
196 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
197 _Enable_copy_move&
198 operator=(_Enable_copy_move const&) noexcept = delete;
199 _Enable_copy_move&
200 operator=(_Enable_copy_move&&) noexcept = default;
201 };
202
203template<typename _Tag>
204 struct _Enable_copy_move<false, false, false, true, _Tag>
205 {
206 constexpr _Enable_copy_move() noexcept = default;
207 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
208 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
209 _Enable_copy_move&
210 operator=(_Enable_copy_move const&) noexcept = delete;
211 _Enable_copy_move&
212 operator=(_Enable_copy_move&&) noexcept = default;
213 };
214
215template<typename _Tag>
216 struct _Enable_copy_move<true, true, true, false, _Tag>
217 {
218 constexpr _Enable_copy_move() noexcept = default;
219 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
220 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
221 _Enable_copy_move&
222 operator=(_Enable_copy_move const&) noexcept = default;
223 _Enable_copy_move&
224 operator=(_Enable_copy_move&&) noexcept = delete;
225 };
226
227template<typename _Tag>
228 struct _Enable_copy_move<false, true, true, false, _Tag>
229 {
230 constexpr _Enable_copy_move() noexcept = default;
231 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
232 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
233 _Enable_copy_move&
234 operator=(_Enable_copy_move const&) noexcept = default;
235 _Enable_copy_move&
236 operator=(_Enable_copy_move&&) noexcept = delete;
237 };
238
239template<typename _Tag>
240 struct _Enable_copy_move<true, false, true, false, _Tag>
241 {
242 constexpr _Enable_copy_move() noexcept = default;
243 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
244 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
245 _Enable_copy_move&
246 operator=(_Enable_copy_move const&) noexcept = delete;
247 _Enable_copy_move&
248 operator=(_Enable_copy_move&&) noexcept = delete;
249 };
250
251template<typename _Tag>
252 struct _Enable_copy_move<false, false, true, false, _Tag>
253 {
254 constexpr _Enable_copy_move() noexcept = default;
255 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
256 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
257 _Enable_copy_move&
258 operator=(_Enable_copy_move const&) noexcept = delete;
259 _Enable_copy_move&
260 operator=(_Enable_copy_move&&) noexcept = delete;
261 };
262
263template<typename _Tag>
264 struct _Enable_copy_move<true, true, false, false, _Tag>
265 {
266 constexpr _Enable_copy_move() noexcept = default;
267 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
268 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
269 _Enable_copy_move&
270 operator=(_Enable_copy_move const&) noexcept = default;
271 _Enable_copy_move&
272 operator=(_Enable_copy_move&&) noexcept = delete;
273 };
274
275template<typename _Tag>
276 struct _Enable_copy_move<false, true, false, false, _Tag>
277 {
278 constexpr _Enable_copy_move() noexcept = default;
279 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
280 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
281 _Enable_copy_move&
282 operator=(_Enable_copy_move const&) noexcept = default;
283 _Enable_copy_move&
284 operator=(_Enable_copy_move&&) noexcept = delete;
285 };
286
287template<typename _Tag>
288 struct _Enable_copy_move<true, false, false, false, _Tag>
289 {
290 constexpr _Enable_copy_move() noexcept = default;
291 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
292 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
293 _Enable_copy_move&
294 operator=(_Enable_copy_move const&) noexcept = delete;
295 _Enable_copy_move&
296 operator=(_Enable_copy_move&&) noexcept = delete;
297 };
298
299template<typename _Tag>
300 struct _Enable_copy_move<false, false, false, false, _Tag>
301 {
302 constexpr _Enable_copy_move() noexcept = default;
303 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
304 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
305 _Enable_copy_move&
306 operator=(_Enable_copy_move const&) noexcept = delete;
307 _Enable_copy_move&
308 operator=(_Enable_copy_move&&) noexcept = delete;
309 };
310
311_GLIBCXX_END_NAMESPACE_VERSION
312} // namespace std
313
314#endif // _ENABLE_SPECIAL_MEMBERS_H
Note: See TracBrowser for help on using the repository browser.