Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/c++/15/bits/enable_special_members.h
1 // <bits/enable_special_members.h> -*- C++ -*- 2 3 // Copyright (C) 2013-2025 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 #ifdef _GLIBCXX_SYSHDR 34 #pragma GCC system_header 35 #endif 36 37 #include <bits/c++config.h> 38 39 namespace std _GLIBCXX_VISIBILITY(default) 40 { 41 _GLIBCXX_BEGIN_NAMESPACE_VERSION 42 /// @cond undocumented 43 44 struct _Enable_default_constructor_tag 45 { 46 explicit constexpr _Enable_default_constructor_tag() = default; 47 }; 48 49 /** 50 * @brief A mixin helper to conditionally enable or disable the default 51 * constructor. 52 * @sa _Enable_special_members 53 */ 54 template<bool _Switch, typename _Tag = void> 55 struct _Enable_default_constructor 56 { 57 constexpr _Enable_default_constructor() noexcept = default; 58 constexpr _Enable_default_constructor(_Enable_default_constructor const&) 59 noexcept = default; 60 constexpr _Enable_default_constructor(_Enable_default_constructor&&) 61 noexcept = default; 62 _Enable_default_constructor& 63 operator=(_Enable_default_constructor const&) noexcept = default; 64 _Enable_default_constructor& 65 operator=(_Enable_default_constructor&&) noexcept = default; 66 67 // Can be used in other ctors. 68 constexpr explicit 69 _Enable_default_constructor(_Enable_default_constructor_tag) { } 70 }; 71 72 73 /** 74 * @brief A mixin helper to conditionally enable or disable the default 75 * destructor. 76 * @sa _Enable_special_members 77 */ 78 template<bool _Switch, typename _Tag = void> 79 struct _Enable_destructor { }; 80 81 /** 82 * @brief A mixin helper to conditionally enable or disable the copy/move 83 * special members. 84 * @sa _Enable_special_members 85 */ 86 template<bool _Copy, bool _CopyAssignment, 87 bool _Move, bool _MoveAssignment, 88 typename _Tag = void> 89 struct _Enable_copy_move { }; 90 91 /** 92 * @brief A mixin helper to conditionally enable or disable the special 93 * members. 94 * 95 * The @c _Tag type parameter is to make mixin bases unique and thus avoid 96 * ambiguities. 97 */ 98 template<bool _Default, bool _Destructor, 99 bool _Copy, bool _CopyAssignment, 100 bool _Move, bool _MoveAssignment, 101 typename _Tag = void> 102 struct _Enable_special_members 103 : private _Enable_default_constructor<_Default, _Tag>, 104 private _Enable_destructor<_Destructor, _Tag>, 105 private _Enable_copy_move<_Copy, _CopyAssignment, 106 _Move, _MoveAssignment, 107 _Tag> 108 { }; 109 110 // Boilerplate follows. 111 112 template<typename _Tag> 113 struct _Enable_default_constructor<false, _Tag> 114 { 115 constexpr _Enable_default_constructor() noexcept = delete; 116 constexpr _Enable_default_constructor(_Enable_default_constructor const&) 117 noexcept = default; 118 constexpr _Enable_default_constructor(_Enable_default_constructor&&) 119 noexcept = default; 120 _Enable_default_constructor& 121 operator=(_Enable_default_constructor const&) noexcept = default; 122 _Enable_default_constructor& 123 operator=(_Enable_default_constructor&&) noexcept = default; 124 125 // Can be used in other ctors. 126 constexpr explicit 127 _Enable_default_constructor(_Enable_default_constructor_tag) { } 128 }; 129 130 template<typename _Tag> 131 struct _Enable_destructor<false, _Tag> 132 { ~_Enable_destructor() noexcept = delete; }; 133 134 template<typename _Tag> 135 struct _Enable_copy_move<false, true, true, true, _Tag> 136 { 137 constexpr _Enable_copy_move() noexcept = default; 138 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 139 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; 140 _Enable_copy_move& 141 operator=(_Enable_copy_move const&) noexcept = default; 142 _Enable_copy_move& 143 operator=(_Enable_copy_move&&) noexcept = default; 144 }; 145 146 template<typename _Tag> 147 struct _Enable_copy_move<true, false, true, true, _Tag> 148 { 149 constexpr _Enable_copy_move() noexcept = default; 150 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; 151 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; 152 _Enable_copy_move& 153 operator=(_Enable_copy_move const&) noexcept = delete; 154 _Enable_copy_move& 155 operator=(_Enable_copy_move&&) noexcept = default; 156 }; 157 158 template<typename _Tag> 159 struct _Enable_copy_move<false, false, true, true, _Tag> 160 { 161 constexpr _Enable_copy_move() noexcept = default; 162 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 163 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; 164 _Enable_copy_move& 165 operator=(_Enable_copy_move const&) noexcept = delete; 166 _Enable_copy_move& 167 operator=(_Enable_copy_move&&) noexcept = default; 168 }; 169 170 template<typename _Tag> 171 struct _Enable_copy_move<true, true, false, true, _Tag> 172 { 173 constexpr _Enable_copy_move() noexcept = default; 174 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; 175 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 176 _Enable_copy_move& 177 operator=(_Enable_copy_move const&) noexcept = default; 178 _Enable_copy_move& 179 operator=(_Enable_copy_move&&) noexcept = default; 180 }; 181 182 template<typename _Tag> 183 struct _Enable_copy_move<false, true, false, true, _Tag> 184 { 185 constexpr _Enable_copy_move() noexcept = default; 186 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 187 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 188 _Enable_copy_move& 189 operator=(_Enable_copy_move const&) noexcept = default; 190 _Enable_copy_move& 191 operator=(_Enable_copy_move&&) noexcept = default; 192 }; 193 194 template<typename _Tag> 195 struct _Enable_copy_move<true, false, false, true, _Tag> 196 { 197 constexpr _Enable_copy_move() noexcept = default; 198 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; 199 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 200 _Enable_copy_move& 201 operator=(_Enable_copy_move const&) noexcept = delete; 202 _Enable_copy_move& 203 operator=(_Enable_copy_move&&) noexcept = default; 204 }; 205 206 template<typename _Tag> 207 struct _Enable_copy_move<false, false, false, true, _Tag> 208 { 209 constexpr _Enable_copy_move() noexcept = default; 210 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 211 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 212 _Enable_copy_move& 213 operator=(_Enable_copy_move const&) noexcept = delete; 214 _Enable_copy_move& 215 operator=(_Enable_copy_move&&) noexcept = default; 216 }; 217 218 template<typename _Tag> 219 struct _Enable_copy_move<true, true, true, false, _Tag> 220 { 221 constexpr _Enable_copy_move() noexcept = default; 222 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; 223 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; 224 _Enable_copy_move& 225 operator=(_Enable_copy_move const&) noexcept = default; 226 _Enable_copy_move& 227 operator=(_Enable_copy_move&&) noexcept = delete; 228 }; 229 230 template<typename _Tag> 231 struct _Enable_copy_move<false, true, true, false, _Tag> 232 { 233 constexpr _Enable_copy_move() noexcept = default; 234 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 235 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; 236 _Enable_copy_move& 237 operator=(_Enable_copy_move const&) noexcept = default; 238 _Enable_copy_move& 239 operator=(_Enable_copy_move&&) noexcept = delete; 240 }; 241 242 template<typename _Tag> 243 struct _Enable_copy_move<true, false, true, false, _Tag> 244 { 245 constexpr _Enable_copy_move() noexcept = default; 246 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; 247 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; 248 _Enable_copy_move& 249 operator=(_Enable_copy_move const&) noexcept = delete; 250 _Enable_copy_move& 251 operator=(_Enable_copy_move&&) noexcept = delete; 252 }; 253 254 template<typename _Tag> 255 struct _Enable_copy_move<false, false, true, false, _Tag> 256 { 257 constexpr _Enable_copy_move() noexcept = default; 258 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 259 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; 260 _Enable_copy_move& 261 operator=(_Enable_copy_move const&) noexcept = delete; 262 _Enable_copy_move& 263 operator=(_Enable_copy_move&&) noexcept = delete; 264 }; 265 266 template<typename _Tag> 267 struct _Enable_copy_move<true, true, false, false, _Tag> 268 { 269 constexpr _Enable_copy_move() noexcept = default; 270 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; 271 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 272 _Enable_copy_move& 273 operator=(_Enable_copy_move const&) noexcept = default; 274 _Enable_copy_move& 275 operator=(_Enable_copy_move&&) noexcept = delete; 276 }; 277 278 template<typename _Tag> 279 struct _Enable_copy_move<false, true, false, false, _Tag> 280 { 281 constexpr _Enable_copy_move() noexcept = default; 282 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 283 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 284 _Enable_copy_move& 285 operator=(_Enable_copy_move const&) noexcept = default; 286 _Enable_copy_move& 287 operator=(_Enable_copy_move&&) noexcept = delete; 288 }; 289 290 template<typename _Tag> 291 struct _Enable_copy_move<true, false, false, false, _Tag> 292 { 293 constexpr _Enable_copy_move() noexcept = default; 294 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; 295 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 296 _Enable_copy_move& 297 operator=(_Enable_copy_move const&) noexcept = delete; 298 _Enable_copy_move& 299 operator=(_Enable_copy_move&&) noexcept = delete; 300 }; 301 302 template<typename _Tag> 303 struct _Enable_copy_move<false, false, false, false, _Tag> 304 { 305 constexpr _Enable_copy_move() noexcept = default; 306 constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; 307 constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; 308 _Enable_copy_move& 309 operator=(_Enable_copy_move const&) noexcept = delete; 310 _Enable_copy_move& 311 operator=(_Enable_copy_move&&) noexcept = delete; 312 }; 313 314 /// @endcond 315 _GLIBCXX_END_NAMESPACE_VERSION 316 } // namespace std 317 318 #endif // _ENABLE_SPECIAL_MEMBERS_H