1 // <bits/enable_special_members.h> -*- C++ -*-
3 // Copyright (C) 2013-2015 Free Software Foundation, Inc.
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)
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.
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.
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/>.
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.
30 #ifndef _ENABLE_SPECIAL_MEMBERS_H
31 #define _ENABLE_SPECIAL_MEMBERS_H 1
33 #pragma GCC system_header
35 namespace std _GLIBCXX_VISIBILITY(default)
37 _GLIBCXX_BEGIN_NAMESPACE_VERSION
40 * @brief A mixin helper to conditionally enable or disable the default
42 * @sa _Enable_special_members
44 template<bool _Switch, typename _Tag = void>
45 struct _Enable_default_constructor { };
49 * @brief A mixin helper to conditionally enable or disable the default
51 * @sa _Enable_special_members
53 template<bool _Switch, typename _Tag = void>
54 struct _Enable_destructor { };
57 * @brief A mixin helper to conditionally enable or disable the copy/move
59 * @sa _Enable_special_members
61 template<bool _Copy, bool _CopyAssignment,
62 bool _Move, bool _MoveAssignment,
64 struct _Enable_copy_move { };
67 * @brief A mixin helper to conditionally enable or disable the special
70 * The @c _Tag type parameter is to make mixin bases unique and thus avoid
73 template<bool _Default, bool _Destructor,
74 bool _Copy, bool _CopyAssignment,
75 bool _Move, bool _MoveAssignment,
77 struct _Enable_special_members
78 : private _Enable_default_constructor<_Default, _Tag>,
79 private _Enable_destructor<_Destructor, _Tag>,
80 private _Enable_copy_move<_Copy, _CopyAssignment,
81 _Move, _MoveAssignment,
85 // Boilerplate follows.
87 template<typename _Tag>
88 struct _Enable_default_constructor<false, _Tag>
89 { constexpr _Enable_default_constructor() noexcept = delete; };
91 template<typename _Tag>
92 struct _Enable_destructor<false, _Tag>
93 { ~_Enable_destructor() noexcept = delete; };
95 template<typename _Tag>
96 struct _Enable_copy_move<false, true, true, true, _Tag>
98 constexpr _Enable_copy_move() noexcept = default;
99 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
100 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
102 operator=(_Enable_copy_move const&) noexcept = default;
104 operator=(_Enable_copy_move&&) noexcept = default;
107 template<typename _Tag>
108 struct _Enable_copy_move<true, false, true, true, _Tag>
110 constexpr _Enable_copy_move() noexcept = default;
111 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
112 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
114 operator=(_Enable_copy_move const&) noexcept = delete;
116 operator=(_Enable_copy_move&&) noexcept = default;
119 template<typename _Tag>
120 struct _Enable_copy_move<false, false, true, true, _Tag>
122 constexpr _Enable_copy_move() noexcept = default;
123 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
124 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
126 operator=(_Enable_copy_move const&) noexcept = delete;
128 operator=(_Enable_copy_move&&) noexcept = default;
131 template<typename _Tag>
132 struct _Enable_copy_move<true, true, false, true, _Tag>
134 constexpr _Enable_copy_move() noexcept = default;
135 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
136 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
138 operator=(_Enable_copy_move const&) noexcept = default;
140 operator=(_Enable_copy_move&&) noexcept = default;
143 template<typename _Tag>
144 struct _Enable_copy_move<false, true, false, true, _Tag>
146 constexpr _Enable_copy_move() noexcept = default;
147 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
148 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
150 operator=(_Enable_copy_move const&) noexcept = default;
152 operator=(_Enable_copy_move&&) noexcept = default;
155 template<typename _Tag>
156 struct _Enable_copy_move<true, false, false, true, _Tag>
158 constexpr _Enable_copy_move() noexcept = default;
159 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
160 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
162 operator=(_Enable_copy_move const&) noexcept = delete;
164 operator=(_Enable_copy_move&&) noexcept = default;
167 template<typename _Tag>
168 struct _Enable_copy_move<false, false, false, true, _Tag>
170 constexpr _Enable_copy_move() noexcept = default;
171 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
172 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
174 operator=(_Enable_copy_move const&) noexcept = delete;
176 operator=(_Enable_copy_move&&) noexcept = default;
179 template<typename _Tag>
180 struct _Enable_copy_move<true, true, true, false, _Tag>
182 constexpr _Enable_copy_move() noexcept = default;
183 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
184 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
186 operator=(_Enable_copy_move const&) noexcept = default;
188 operator=(_Enable_copy_move&&) noexcept = delete;
191 template<typename _Tag>
192 struct _Enable_copy_move<false, true, true, false, _Tag>
194 constexpr _Enable_copy_move() noexcept = default;
195 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
196 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
198 operator=(_Enable_copy_move const&) noexcept = default;
200 operator=(_Enable_copy_move&&) noexcept = delete;
203 template<typename _Tag>
204 struct _Enable_copy_move<true, false, true, false, _Tag>
206 constexpr _Enable_copy_move() noexcept = default;
207 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
208 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
210 operator=(_Enable_copy_move const&) noexcept = delete;
212 operator=(_Enable_copy_move&&) noexcept = delete;
215 template<typename _Tag>
216 struct _Enable_copy_move<false, false, true, false, _Tag>
218 constexpr _Enable_copy_move() noexcept = default;
219 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
220 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default;
222 operator=(_Enable_copy_move const&) noexcept = delete;
224 operator=(_Enable_copy_move&&) noexcept = delete;
227 template<typename _Tag>
228 struct _Enable_copy_move<true, true, false, false, _Tag>
230 constexpr _Enable_copy_move() noexcept = default;
231 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
232 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
234 operator=(_Enable_copy_move const&) noexcept = default;
236 operator=(_Enable_copy_move&&) noexcept = delete;
239 template<typename _Tag>
240 struct _Enable_copy_move<false, true, false, false, _Tag>
242 constexpr _Enable_copy_move() noexcept = default;
243 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
244 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
246 operator=(_Enable_copy_move const&) noexcept = default;
248 operator=(_Enable_copy_move&&) noexcept = delete;
251 template<typename _Tag>
252 struct _Enable_copy_move<true, false, false, false, _Tag>
254 constexpr _Enable_copy_move() noexcept = default;
255 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default;
256 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
258 operator=(_Enable_copy_move const&) noexcept = delete;
260 operator=(_Enable_copy_move&&) noexcept = delete;
263 template<typename _Tag>
264 struct _Enable_copy_move<false, false, false, false, _Tag>
266 constexpr _Enable_copy_move() noexcept = default;
267 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete;
268 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete;
270 operator=(_Enable_copy_move const&) noexcept = delete;
272 operator=(_Enable_copy_move&&) noexcept = delete;
275 _GLIBCXX_END_NAMESPACE_VERSION
278 #endif // _ENABLE_SPECIAL_MEMBERS_H