| 1 | // C++11 <type_traits> -*- C++ -*- |
| 2 | |
| 3 | // Copyright (C) 2007-2022 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 include/type_traits |
| 26 | * This is a Standard C++ Library header. |
| 27 | */ |
| 28 | |
| 29 | #ifndef _GLIBCXX_TYPE_TRAITS |
| 30 | #define _GLIBCXX_TYPE_TRAITS 1 |
| 31 | |
| 32 | #pragma GCC system_header |
| 33 | |
| 34 | #if __cplusplus < 201103L |
| 35 | # include <bits/c++0x_warning.h> |
| 36 | #else |
| 37 | |
| 38 | #include <bits/c++config.h> |
| 39 | |
| 40 | namespace std _GLIBCXX_VISIBILITY(default) |
| 41 | { |
| 42 | _GLIBCXX_BEGIN_NAMESPACE_VERSION |
| 43 | |
| 44 | template<typename _Tp> |
| 45 | class reference_wrapper; |
| 46 | |
| 47 | /** |
| 48 | * @defgroup metaprogramming Metaprogramming |
| 49 | * @ingroup utilities |
| 50 | * |
| 51 | * Template utilities for compile-time introspection and modification, |
| 52 | * including type classification traits, type property inspection traits |
| 53 | * and type transformation traits. |
| 54 | * |
| 55 | * @since C++11 |
| 56 | * |
| 57 | * @{ |
| 58 | */ |
| 59 | |
| 60 | /// integral_constant |
| 61 | template<typename _Tp, _Tp __v> |
| 62 | struct integral_constant |
| 63 | { |
| 64 | static constexpr _Tp value = __v; |
| 65 | typedef _Tp value_type; |
| 66 | typedef integral_constant<_Tp, __v> type; |
| 67 | constexpr operator value_type() const noexcept { return value; } |
| 68 | #if __cplusplus > 201103L |
| 69 | |
| 70 | #define __cpp_lib_integral_constant_callable 201304L |
| 71 | |
| 72 | constexpr value_type operator()() const noexcept { return value; } |
| 73 | #endif |
| 74 | }; |
| 75 | |
| 76 | #if ! __cpp_inline_variables |
| 77 | template<typename _Tp, _Tp __v> |
| 78 | constexpr _Tp integral_constant<_Tp, __v>::value; |
| 79 | #endif |
| 80 | |
| 81 | /// The type used as a compile-time boolean with true value. |
| 82 | using true_type = integral_constant<bool, true>; |
| 83 | |
| 84 | /// The type used as a compile-time boolean with false value. |
| 85 | using false_type = integral_constant<bool, false>; |
| 86 | |
| 87 | /// @cond undocumented |
| 88 | /// bool_constant for C++11 |
| 89 | template<bool __v> |
| 90 | using __bool_constant = integral_constant<bool, __v>; |
| 91 | /// @endcond |
| 92 | |
| 93 | #if __cplusplus >= 201703L |
| 94 | # define __cpp_lib_bool_constant 201505L |
| 95 | /// Alias template for compile-time boolean constant types. |
| 96 | /// @since C++17 |
| 97 | template<bool __v> |
| 98 | using bool_constant = integral_constant<bool, __v>; |
| 99 | #endif |
| 100 | |
| 101 | // Metaprogramming helper types. |
| 102 | |
| 103 | template<bool> |
| 104 | struct __conditional |
| 105 | { |
| 106 | template<typename _Tp, typename> |
| 107 | using type = _Tp; |
| 108 | }; |
| 109 | |
| 110 | template<> |
| 111 | struct __conditional<false> |
| 112 | { |
| 113 | template<typename, typename _Up> |
| 114 | using type = _Up; |
| 115 | }; |
| 116 | |
| 117 | // More efficient version of std::conditional_t for internal use (and C++11) |
| 118 | template<bool _Cond, typename _If, typename _Else> |
| 119 | using __conditional_t |
| 120 | = typename __conditional<_Cond>::template type<_If, _Else>; |
| 121 | |
| 122 | /// @cond undocumented |
| 123 | template <typename _Type> |
| 124 | struct __type_identity |
| 125 | { using type = _Type; }; |
| 126 | |
| 127 | template<typename _Tp> |
| 128 | using __type_identity_t = typename __type_identity<_Tp>::type; |
| 129 | |
| 130 | template<typename...> |
| 131 | struct __or_; |
| 132 | |
| 133 | template<> |
| 134 | struct __or_<> |
| 135 | : public false_type |
| 136 | { }; |
| 137 | |
| 138 | template<typename _B1> |
| 139 | struct __or_<_B1> |
| 140 | : public _B1 |
| 141 | { }; |
| 142 | |
| 143 | template<typename _B1, typename _B2> |
| 144 | struct __or_<_B1, _B2> |
| 145 | : public __conditional_t<_B1::value, _B1, _B2> |
| 146 | { }; |
| 147 | |
| 148 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> |
| 149 | struct __or_<_B1, _B2, _B3, _Bn...> |
| 150 | : public __conditional_t<_B1::value, _B1, __or_<_B2, _B3, _Bn...>> |
| 151 | { }; |
| 152 | |
| 153 | template<typename...> |
| 154 | struct __and_; |
| 155 | |
| 156 | template<> |
| 157 | struct __and_<> |
| 158 | : public true_type |
| 159 | { }; |
| 160 | |
| 161 | template<typename _B1> |
| 162 | struct __and_<_B1> |
| 163 | : public _B1 |
| 164 | { }; |
| 165 | |
| 166 | template<typename _B1, typename _B2> |
| 167 | struct __and_<_B1, _B2> |
| 168 | : public __conditional_t<_B1::value, _B2, _B1> |
| 169 | { }; |
| 170 | |
| 171 | template<typename _B1, typename _B2, typename _B3, typename... _Bn> |
| 172 | struct __and_<_B1, _B2, _B3, _Bn...> |
| 173 | : public __conditional_t<_B1::value, __and_<_B2, _B3, _Bn...>, _B1> |
| 174 | { }; |
| 175 | |
| 176 | template<typename _Pp> |
| 177 | struct __not_ |
| 178 | : public __bool_constant<!bool(_Pp::value)> |
| 179 | { }; |
| 180 | /// @endcond |
| 181 | |
| 182 | #if __cplusplus >= 201703L |
| 183 | |
| 184 | /// @cond undocumented |
| 185 | template<typename... _Bn> |
| 186 | inline constexpr bool __or_v = __or_<_Bn...>::value; |
| 187 | template<typename... _Bn> |
| 188 | inline constexpr bool __and_v = __and_<_Bn...>::value; |
| 189 | /// @endcond |
| 190 | |
| 191 | #define __cpp_lib_logical_traits 201510L |
| 192 | |
| 193 | template<typename... _Bn> |
| 194 | struct conjunction |
| 195 | : __and_<_Bn...> |
| 196 | { }; |
| 197 | |
| 198 | template<typename... _Bn> |
| 199 | struct disjunction |
| 200 | : __or_<_Bn...> |
| 201 | { }; |
| 202 | |
| 203 | template<typename _Pp> |
| 204 | struct negation |
| 205 | : __not_<_Pp> |
| 206 | { }; |
| 207 | |
| 208 | /** @ingroup variable_templates |
| 209 | * @{ |
| 210 | */ |
| 211 | template<typename... _Bn> |
| 212 | inline constexpr bool conjunction_v = conjunction<_Bn...>::value; |
| 213 | |
| 214 | template<typename... _Bn> |
| 215 | inline constexpr bool disjunction_v = disjunction<_Bn...>::value; |
| 216 | |
| 217 | template<typename _Pp> |
| 218 | inline constexpr bool negation_v = negation<_Pp>::value; |
| 219 | /// @} |
| 220 | |
| 221 | #endif // C++17 |
| 222 | |
| 223 | // Forward declarations |
| 224 | template<typename> |
| 225 | struct is_reference; |
| 226 | template<typename> |
| 227 | struct is_function; |
| 228 | template<typename> |
| 229 | struct is_void; |
| 230 | template<typename> |
| 231 | struct remove_cv; |
| 232 | template<typename> |
| 233 | struct is_const; |
| 234 | |
| 235 | /// @cond undocumented |
| 236 | template<typename> |
| 237 | struct __is_array_unknown_bounds; |
| 238 | |
| 239 | // Helper functions that return false_type for incomplete classes, |
| 240 | // incomplete unions and arrays of known bound from those. |
| 241 | |
| 242 | template <typename _Tp, size_t = sizeof(_Tp)> |
| 243 | constexpr true_type __is_complete_or_unbounded(__type_identity<_Tp>) |
| 244 | { return {}; } |
| 245 | |
| 246 | template <typename _TypeIdentity, |
| 247 | typename _NestedType = typename _TypeIdentity::type> |
| 248 | constexpr typename __or_< |
| 249 | is_reference<_NestedType>, |
| 250 | is_function<_NestedType>, |
| 251 | is_void<_NestedType>, |
| 252 | __is_array_unknown_bounds<_NestedType> |
| 253 | >::type __is_complete_or_unbounded(_TypeIdentity) |
| 254 | { return {}; } |
| 255 | |
| 256 | // For several sfinae-friendly trait implementations we transport both the |
| 257 | // result information (as the member type) and the failure information (no |
| 258 | // member type). This is very similar to std::enable_if, but we cannot use |
| 259 | // them, because we need to derive from them as an implementation detail. |
| 260 | |
| 261 | template<typename _Tp> |
| 262 | struct __success_type |
| 263 | { typedef _Tp type; }; |
| 264 | |
| 265 | struct __failure_type |
| 266 | { }; |
| 267 | |
| 268 | // __remove_cv_t (std::remove_cv_t for C++11). |
| 269 | template<typename _Tp> |
| 270 | using __remove_cv_t = typename remove_cv<_Tp>::type; |
| 271 | |
| 272 | // Primary type categories. |
| 273 | |
| 274 | template<typename> |
| 275 | struct __is_void_helper |
| 276 | : public false_type { }; |
| 277 | |
| 278 | template<> |
| 279 | struct __is_void_helper<void> |
| 280 | : public true_type { }; |
| 281 | /// @endcond |
| 282 | |
| 283 | /// is_void |
| 284 | template<typename _Tp> |
| 285 | struct is_void |
| 286 | : public __is_void_helper<__remove_cv_t<_Tp>>::type |
| 287 | { }; |
| 288 | |
| 289 | /// @cond undocumented |
| 290 | template<typename> |
| 291 | struct __is_integral_helper |
| 292 | : public false_type { }; |
| 293 | |
| 294 | template<> |
| 295 | struct __is_integral_helper<bool> |
| 296 | : public true_type { }; |
| 297 | |
| 298 | template<> |
| 299 | struct __is_integral_helper<char> |
| 300 | : public true_type { }; |
| 301 | |
| 302 | template<> |
| 303 | struct __is_integral_helper<signed char> |
| 304 | : public true_type { }; |
| 305 | |
| 306 | template<> |
| 307 | struct __is_integral_helper<unsigned char> |
| 308 | : public true_type { }; |
| 309 | |
| 310 | // We want is_integral<wchar_t> to be true (and make_signed/unsigned to work) |
| 311 | // even when libc doesn't provide working <wchar.h> and related functions, |
| 312 | // so don't check _GLIBCXX_USE_WCHAR_T here. |
| 313 | template<> |
| 314 | struct __is_integral_helper<wchar_t> |
| 315 | : public true_type { }; |
| 316 | |
| 317 | #ifdef _GLIBCXX_USE_CHAR8_T |
| 318 | template<> |
| 319 | struct __is_integral_helper<char8_t> |
| 320 | : public true_type { }; |
| 321 | #endif |
| 322 | |
| 323 | template<> |
| 324 | struct __is_integral_helper<char16_t> |
| 325 | : public true_type { }; |
| 326 | |
| 327 | template<> |
| 328 | struct __is_integral_helper<char32_t> |
| 329 | : public true_type { }; |
| 330 | |
| 331 | template<> |
| 332 | struct __is_integral_helper<short> |
| 333 | : public true_type { }; |
| 334 | |
| 335 | template<> |
| 336 | struct __is_integral_helper<unsigned short> |
| 337 | : public true_type { }; |
| 338 | |
| 339 | template<> |
| 340 | struct __is_integral_helper<int> |
| 341 | : public true_type { }; |
| 342 | |
| 343 | template<> |
| 344 | struct __is_integral_helper<unsigned int> |
| 345 | : public true_type { }; |
| 346 | |
| 347 | template<> |
| 348 | struct __is_integral_helper<long> |
| 349 | : public true_type { }; |
| 350 | |
| 351 | template<> |
| 352 | struct __is_integral_helper<unsigned long> |
| 353 | : public true_type { }; |
| 354 | |
| 355 | template<> |
| 356 | struct __is_integral_helper<long long> |
| 357 | : public true_type { }; |
| 358 | |
| 359 | template<> |
| 360 | struct __is_integral_helper<unsigned long long> |
| 361 | : public true_type { }; |
| 362 | |
| 363 | // Conditionalizing on __STRICT_ANSI__ here will break any port that |
| 364 | // uses one of these types for size_t. |
| 365 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
| 366 | __extension__ |
| 367 | template<> |
| 368 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> |
| 369 | : public true_type { }; |
| 370 | |
| 371 | __extension__ |
| 372 | template<> |
| 373 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> |
| 374 | : public true_type { }; |
| 375 | #endif |
| 376 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
| 377 | __extension__ |
| 378 | template<> |
| 379 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> |
| 380 | : public true_type { }; |
| 381 | |
| 382 | __extension__ |
| 383 | template<> |
| 384 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> |
| 385 | : public true_type { }; |
| 386 | #endif |
| 387 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
| 388 | __extension__ |
| 389 | template<> |
| 390 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> |
| 391 | : public true_type { }; |
| 392 | |
| 393 | __extension__ |
| 394 | template<> |
| 395 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> |
| 396 | : public true_type { }; |
| 397 | #endif |
| 398 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
| 399 | __extension__ |
| 400 | template<> |
| 401 | struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> |
| 402 | : public true_type { }; |
| 403 | |
| 404 | __extension__ |
| 405 | template<> |
| 406 | struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> |
| 407 | : public true_type { }; |
| 408 | #endif |
| 409 | /// @endcond |
| 410 | |
| 411 | /// is_integral |
| 412 | template<typename _Tp> |
| 413 | struct is_integral |
| 414 | : public __is_integral_helper<__remove_cv_t<_Tp>>::type |
| 415 | { }; |
| 416 | |
| 417 | /// @cond undocumented |
| 418 | template<typename> |
| 419 | struct __is_floating_point_helper |
| 420 | : public false_type { }; |
| 421 | |
| 422 | template<> |
| 423 | struct __is_floating_point_helper<float> |
| 424 | : public true_type { }; |
| 425 | |
| 426 | template<> |
| 427 | struct __is_floating_point_helper<double> |
| 428 | : public true_type { }; |
| 429 | |
| 430 | template<> |
| 431 | struct __is_floating_point_helper<long double> |
| 432 | : public true_type { }; |
| 433 | |
| 434 | #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__) |
| 435 | template<> |
| 436 | struct __is_floating_point_helper<__float128> |
| 437 | : public true_type { }; |
| 438 | #endif |
| 439 | /// @endcond |
| 440 | |
| 441 | /// is_floating_point |
| 442 | template<typename _Tp> |
| 443 | struct is_floating_point |
| 444 | : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type |
| 445 | { }; |
| 446 | |
| 447 | /// is_array |
| 448 | template<typename> |
| 449 | struct is_array |
| 450 | : public false_type { }; |
| 451 | |
| 452 | template<typename _Tp, std::size_t _Size> |
| 453 | struct is_array<_Tp[_Size]> |
| 454 | : public true_type { }; |
| 455 | |
| 456 | template<typename _Tp> |
| 457 | struct is_array<_Tp[]> |
| 458 | : public true_type { }; |
| 459 | |
| 460 | template<typename> |
| 461 | struct __is_pointer_helper |
| 462 | : public false_type { }; |
| 463 | |
| 464 | template<typename _Tp> |
| 465 | struct __is_pointer_helper<_Tp*> |
| 466 | : public true_type { }; |
| 467 | |
| 468 | /// is_pointer |
| 469 | template<typename _Tp> |
| 470 | struct is_pointer |
| 471 | : public __is_pointer_helper<__remove_cv_t<_Tp>>::type |
| 472 | { }; |
| 473 | |
| 474 | /// is_lvalue_reference |
| 475 | template<typename> |
| 476 | struct is_lvalue_reference |
| 477 | : public false_type { }; |
| 478 | |
| 479 | template<typename _Tp> |
| 480 | struct is_lvalue_reference<_Tp&> |
| 481 | : public true_type { }; |
| 482 | |
| 483 | /// is_rvalue_reference |
| 484 | template<typename> |
| 485 | struct is_rvalue_reference |
| 486 | : public false_type { }; |
| 487 | |
| 488 | template<typename _Tp> |
| 489 | struct is_rvalue_reference<_Tp&&> |
| 490 | : public true_type { }; |
| 491 | |
| 492 | template<typename> |
| 493 | struct __is_member_object_pointer_helper |
| 494 | : public false_type { }; |
| 495 | |
| 496 | template<typename _Tp, typename _Cp> |
| 497 | struct __is_member_object_pointer_helper<_Tp _Cp::*> |
| 498 | : public __not_<is_function<_Tp>>::type { }; |
| 499 | |
| 500 | /// is_member_object_pointer |
| 501 | template<typename _Tp> |
| 502 | struct is_member_object_pointer |
| 503 | : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type |
| 504 | { }; |
| 505 | |
| 506 | template<typename> |
| 507 | struct __is_member_function_pointer_helper |
| 508 | : public false_type { }; |
| 509 | |
| 510 | template<typename _Tp, typename _Cp> |
| 511 | struct __is_member_function_pointer_helper<_Tp _Cp::*> |
| 512 | : public is_function<_Tp>::type { }; |
| 513 | |
| 514 | /// is_member_function_pointer |
| 515 | template<typename _Tp> |
| 516 | struct is_member_function_pointer |
| 517 | : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type |
| 518 | { }; |
| 519 | |
| 520 | /// is_enum |
| 521 | template<typename _Tp> |
| 522 | struct is_enum |
| 523 | : public integral_constant<bool, __is_enum(_Tp)> |
| 524 | { }; |
| 525 | |
| 526 | /// is_union |
| 527 | template<typename _Tp> |
| 528 | struct is_union |
| 529 | : public integral_constant<bool, __is_union(_Tp)> |
| 530 | { }; |
| 531 | |
| 532 | /// is_class |
| 533 | template<typename _Tp> |
| 534 | struct is_class |
| 535 | : public integral_constant<bool, __is_class(_Tp)> |
| 536 | { }; |
| 537 | |
| 538 | /// is_function |
| 539 | template<typename _Tp> |
| 540 | struct is_function |
| 541 | : public __bool_constant<!is_const<const _Tp>::value> { }; |
| 542 | |
| 543 | template<typename _Tp> |
| 544 | struct is_function<_Tp&> |
| 545 | : public false_type { }; |
| 546 | |
| 547 | template<typename _Tp> |
| 548 | struct is_function<_Tp&&> |
| 549 | : public false_type { }; |
| 550 | |
| 551 | #define __cpp_lib_is_null_pointer 201309L |
| 552 | |
| 553 | template<typename> |
| 554 | struct __is_null_pointer_helper |
| 555 | : public false_type { }; |
| 556 | |
| 557 | template<> |
| 558 | struct __is_null_pointer_helper<std::nullptr_t> |
| 559 | : public true_type { }; |
| 560 | |
| 561 | /// is_null_pointer (LWG 2247). |
| 562 | template<typename _Tp> |
| 563 | struct is_null_pointer |
| 564 | : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type |
| 565 | { }; |
| 566 | |
| 567 | /// __is_nullptr_t (deprecated extension). |
| 568 | /// @deprecated Non-standard. Use `is_null_pointer` instead. |
| 569 | template<typename _Tp> |
| 570 | struct __is_nullptr_t |
| 571 | : public is_null_pointer<_Tp> |
| 572 | { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer" ); |
| 573 | |
| 574 | // Composite type categories. |
| 575 | |
| 576 | /// is_reference |
| 577 | template<typename _Tp> |
| 578 | struct is_reference |
| 579 | : public __or_<is_lvalue_reference<_Tp>, |
| 580 | is_rvalue_reference<_Tp>>::type |
| 581 | { }; |
| 582 | |
| 583 | /// is_arithmetic |
| 584 | template<typename _Tp> |
| 585 | struct is_arithmetic |
| 586 | : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type |
| 587 | { }; |
| 588 | |
| 589 | /// is_fundamental |
| 590 | template<typename _Tp> |
| 591 | struct is_fundamental |
| 592 | : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, |
| 593 | is_null_pointer<_Tp>>::type |
| 594 | { }; |
| 595 | |
| 596 | /// is_object |
| 597 | template<typename _Tp> |
| 598 | struct is_object |
| 599 | : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, |
| 600 | is_void<_Tp>>>::type |
| 601 | { }; |
| 602 | |
| 603 | template<typename> |
| 604 | struct is_member_pointer; |
| 605 | |
| 606 | /// is_scalar |
| 607 | template<typename _Tp> |
| 608 | struct is_scalar |
| 609 | : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, |
| 610 | is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type |
| 611 | { }; |
| 612 | |
| 613 | /// is_compound |
| 614 | template<typename _Tp> |
| 615 | struct is_compound |
| 616 | : public __not_<is_fundamental<_Tp>>::type { }; |
| 617 | |
| 618 | /// @cond undocumented |
| 619 | template<typename _Tp> |
| 620 | struct __is_member_pointer_helper |
| 621 | : public false_type { }; |
| 622 | |
| 623 | template<typename _Tp, typename _Cp> |
| 624 | struct __is_member_pointer_helper<_Tp _Cp::*> |
| 625 | : public true_type { }; |
| 626 | /// @endcond |
| 627 | |
| 628 | /// is_member_pointer |
| 629 | template<typename _Tp> |
| 630 | struct is_member_pointer |
| 631 | : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type |
| 632 | { }; |
| 633 | |
| 634 | template<typename, typename> |
| 635 | struct is_same; |
| 636 | |
| 637 | /// @cond undocumented |
| 638 | template<typename _Tp, typename... _Types> |
| 639 | using __is_one_of = __or_<is_same<_Tp, _Types>...>; |
| 640 | |
| 641 | // Check if a type is one of the signed integer types. |
| 642 | __extension__ |
| 643 | template<typename _Tp> |
| 644 | using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>, |
| 645 | signed char, signed short, signed int, signed long, |
| 646 | signed long long |
| 647 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
| 648 | , signed __GLIBCXX_TYPE_INT_N_0 |
| 649 | #endif |
| 650 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
| 651 | , signed __GLIBCXX_TYPE_INT_N_1 |
| 652 | #endif |
| 653 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
| 654 | , signed __GLIBCXX_TYPE_INT_N_2 |
| 655 | #endif |
| 656 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
| 657 | , signed __GLIBCXX_TYPE_INT_N_3 |
| 658 | #endif |
| 659 | >; |
| 660 | |
| 661 | // Check if a type is one of the unsigned integer types. |
| 662 | __extension__ |
| 663 | template<typename _Tp> |
| 664 | using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>, |
| 665 | unsigned char, unsigned short, unsigned int, unsigned long, |
| 666 | unsigned long long |
| 667 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
| 668 | , unsigned __GLIBCXX_TYPE_INT_N_0 |
| 669 | #endif |
| 670 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
| 671 | , unsigned __GLIBCXX_TYPE_INT_N_1 |
| 672 | #endif |
| 673 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
| 674 | , unsigned __GLIBCXX_TYPE_INT_N_2 |
| 675 | #endif |
| 676 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
| 677 | , unsigned __GLIBCXX_TYPE_INT_N_3 |
| 678 | #endif |
| 679 | >; |
| 680 | |
| 681 | // Check if a type is one of the signed or unsigned integer types. |
| 682 | template<typename _Tp> |
| 683 | using __is_standard_integer |
| 684 | = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>; |
| 685 | |
| 686 | // __void_t (std::void_t for C++11) |
| 687 | template<typename...> using __void_t = void; |
| 688 | |
| 689 | // Utility to detect referenceable types ([defns.referenceable]). |
| 690 | |
| 691 | template<typename _Tp, typename = void> |
| 692 | struct __is_referenceable |
| 693 | : public false_type |
| 694 | { }; |
| 695 | |
| 696 | template<typename _Tp> |
| 697 | struct __is_referenceable<_Tp, __void_t<_Tp&>> |
| 698 | : public true_type |
| 699 | { }; |
| 700 | /// @endcond |
| 701 | |
| 702 | // Type properties. |
| 703 | |
| 704 | /// is_const |
| 705 | template<typename> |
| 706 | struct is_const |
| 707 | : public false_type { }; |
| 708 | |
| 709 | template<typename _Tp> |
| 710 | struct is_const<_Tp const> |
| 711 | : public true_type { }; |
| 712 | |
| 713 | /// is_volatile |
| 714 | template<typename> |
| 715 | struct is_volatile |
| 716 | : public false_type { }; |
| 717 | |
| 718 | template<typename _Tp> |
| 719 | struct is_volatile<_Tp volatile> |
| 720 | : public true_type { }; |
| 721 | |
| 722 | /// is_trivial |
| 723 | template<typename _Tp> |
| 724 | struct is_trivial |
| 725 | : public integral_constant<bool, __is_trivial(_Tp)> |
| 726 | { |
| 727 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 728 | "template argument must be a complete class or an unbounded array" ); |
| 729 | }; |
| 730 | |
| 731 | /// is_trivially_copyable |
| 732 | template<typename _Tp> |
| 733 | struct is_trivially_copyable |
| 734 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> |
| 735 | { |
| 736 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 737 | "template argument must be a complete class or an unbounded array" ); |
| 738 | }; |
| 739 | |
| 740 | /// is_standard_layout |
| 741 | template<typename _Tp> |
| 742 | struct is_standard_layout |
| 743 | : public integral_constant<bool, __is_standard_layout(_Tp)> |
| 744 | { |
| 745 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 746 | "template argument must be a complete class or an unbounded array" ); |
| 747 | }; |
| 748 | |
| 749 | /** is_pod |
| 750 | * @deprecated Deprecated in C++20. |
| 751 | * Use `is_standard_layout && is_trivial` instead. |
| 752 | */ |
| 753 | // Could use is_standard_layout && is_trivial instead of the builtin. |
| 754 | template<typename _Tp> |
| 755 | struct |
| 756 | _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead" ) |
| 757 | is_pod |
| 758 | : public integral_constant<bool, __is_pod(_Tp)> |
| 759 | { |
| 760 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 761 | "template argument must be a complete class or an unbounded array" ); |
| 762 | }; |
| 763 | |
| 764 | /** is_literal_type |
| 765 | * @deprecated Deprecated in C++17, removed in C++20. |
| 766 | * The idea of a literal type isn't useful. |
| 767 | */ |
| 768 | template<typename _Tp> |
| 769 | struct |
| 770 | _GLIBCXX17_DEPRECATED |
| 771 | is_literal_type |
| 772 | : public integral_constant<bool, __is_literal_type(_Tp)> |
| 773 | { |
| 774 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 775 | "template argument must be a complete class or an unbounded array" ); |
| 776 | }; |
| 777 | |
| 778 | /// is_empty |
| 779 | template<typename _Tp> |
| 780 | struct is_empty |
| 781 | : public integral_constant<bool, __is_empty(_Tp)> |
| 782 | { }; |
| 783 | |
| 784 | /// is_polymorphic |
| 785 | template<typename _Tp> |
| 786 | struct is_polymorphic |
| 787 | : public integral_constant<bool, __is_polymorphic(_Tp)> |
| 788 | { }; |
| 789 | |
| 790 | #if __cplusplus >= 201402L |
| 791 | #define __cpp_lib_is_final 201402L |
| 792 | /// is_final |
| 793 | /// @since C++14 |
| 794 | template<typename _Tp> |
| 795 | struct is_final |
| 796 | : public integral_constant<bool, __is_final(_Tp)> |
| 797 | { }; |
| 798 | #endif |
| 799 | |
| 800 | /// is_abstract |
| 801 | template<typename _Tp> |
| 802 | struct is_abstract |
| 803 | : public integral_constant<bool, __is_abstract(_Tp)> |
| 804 | { }; |
| 805 | |
| 806 | /// @cond undocumented |
| 807 | template<typename _Tp, |
| 808 | bool = is_arithmetic<_Tp>::value> |
| 809 | struct __is_signed_helper |
| 810 | : public false_type { }; |
| 811 | |
| 812 | template<typename _Tp> |
| 813 | struct __is_signed_helper<_Tp, true> |
| 814 | : public integral_constant<bool, _Tp(-1) < _Tp(0)> |
| 815 | { }; |
| 816 | /// @endcond |
| 817 | |
| 818 | /// is_signed |
| 819 | template<typename _Tp> |
| 820 | struct is_signed |
| 821 | : public __is_signed_helper<_Tp>::type |
| 822 | { }; |
| 823 | |
| 824 | /// is_unsigned |
| 825 | template<typename _Tp> |
| 826 | struct is_unsigned |
| 827 | : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> |
| 828 | { }; |
| 829 | |
| 830 | /// @cond undocumented |
| 831 | template<typename _Tp, typename _Up = _Tp&&> |
| 832 | _Up |
| 833 | __declval(int); |
| 834 | |
| 835 | template<typename _Tp> |
| 836 | _Tp |
| 837 | __declval(long); |
| 838 | /// @endcond |
| 839 | |
| 840 | template<typename _Tp> |
| 841 | auto declval() noexcept -> decltype(__declval<_Tp>(0)); |
| 842 | |
| 843 | template<typename, unsigned = 0> |
| 844 | struct extent; |
| 845 | |
| 846 | template<typename> |
| 847 | struct remove_all_extents; |
| 848 | |
| 849 | /// @cond undocumented |
| 850 | template<typename _Tp> |
| 851 | struct __is_array_known_bounds |
| 852 | : public integral_constant<bool, (extent<_Tp>::value > 0)> |
| 853 | { }; |
| 854 | |
| 855 | template<typename _Tp> |
| 856 | struct __is_array_unknown_bounds |
| 857 | : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> |
| 858 | { }; |
| 859 | |
| 860 | // Destructible and constructible type properties. |
| 861 | |
| 862 | // In N3290 is_destructible does not say anything about function |
| 863 | // types and abstract types, see LWG 2049. This implementation |
| 864 | // describes function types as non-destructible and all complete |
| 865 | // object types as destructible, iff the explicit destructor |
| 866 | // call expression is wellformed. |
| 867 | struct __do_is_destructible_impl |
| 868 | { |
| 869 | template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> |
| 870 | static true_type __test(int); |
| 871 | |
| 872 | template<typename> |
| 873 | static false_type __test(...); |
| 874 | }; |
| 875 | |
| 876 | template<typename _Tp> |
| 877 | struct __is_destructible_impl |
| 878 | : public __do_is_destructible_impl |
| 879 | { |
| 880 | typedef decltype(__test<_Tp>(0)) type; |
| 881 | }; |
| 882 | |
| 883 | template<typename _Tp, |
| 884 | bool = __or_<is_void<_Tp>, |
| 885 | __is_array_unknown_bounds<_Tp>, |
| 886 | is_function<_Tp>>::value, |
| 887 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> |
| 888 | struct __is_destructible_safe; |
| 889 | |
| 890 | template<typename _Tp> |
| 891 | struct __is_destructible_safe<_Tp, false, false> |
| 892 | : public __is_destructible_impl<typename |
| 893 | remove_all_extents<_Tp>::type>::type |
| 894 | { }; |
| 895 | |
| 896 | template<typename _Tp> |
| 897 | struct __is_destructible_safe<_Tp, true, false> |
| 898 | : public false_type { }; |
| 899 | |
| 900 | template<typename _Tp> |
| 901 | struct __is_destructible_safe<_Tp, false, true> |
| 902 | : public true_type { }; |
| 903 | /// @endcond |
| 904 | |
| 905 | /// is_destructible |
| 906 | template<typename _Tp> |
| 907 | struct is_destructible |
| 908 | : public __is_destructible_safe<_Tp>::type |
| 909 | { |
| 910 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 911 | "template argument must be a complete class or an unbounded array" ); |
| 912 | }; |
| 913 | |
| 914 | /// @cond undocumented |
| 915 | |
| 916 | // is_nothrow_destructible requires that is_destructible is |
| 917 | // satisfied as well. We realize that by mimicing the |
| 918 | // implementation of is_destructible but refer to noexcept(expr) |
| 919 | // instead of decltype(expr). |
| 920 | struct __do_is_nt_destructible_impl |
| 921 | { |
| 922 | template<typename _Tp> |
| 923 | static __bool_constant<noexcept(declval<_Tp&>().~_Tp())> |
| 924 | __test(int); |
| 925 | |
| 926 | template<typename> |
| 927 | static false_type __test(...); |
| 928 | }; |
| 929 | |
| 930 | template<typename _Tp> |
| 931 | struct __is_nt_destructible_impl |
| 932 | : public __do_is_nt_destructible_impl |
| 933 | { |
| 934 | typedef decltype(__test<_Tp>(0)) type; |
| 935 | }; |
| 936 | |
| 937 | template<typename _Tp, |
| 938 | bool = __or_<is_void<_Tp>, |
| 939 | __is_array_unknown_bounds<_Tp>, |
| 940 | is_function<_Tp>>::value, |
| 941 | bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> |
| 942 | struct __is_nt_destructible_safe; |
| 943 | |
| 944 | template<typename _Tp> |
| 945 | struct __is_nt_destructible_safe<_Tp, false, false> |
| 946 | : public __is_nt_destructible_impl<typename |
| 947 | remove_all_extents<_Tp>::type>::type |
| 948 | { }; |
| 949 | |
| 950 | template<typename _Tp> |
| 951 | struct __is_nt_destructible_safe<_Tp, true, false> |
| 952 | : public false_type { }; |
| 953 | |
| 954 | template<typename _Tp> |
| 955 | struct __is_nt_destructible_safe<_Tp, false, true> |
| 956 | : public true_type { }; |
| 957 | /// @endcond |
| 958 | |
| 959 | /// is_nothrow_destructible |
| 960 | template<typename _Tp> |
| 961 | struct is_nothrow_destructible |
| 962 | : public __is_nt_destructible_safe<_Tp>::type |
| 963 | { |
| 964 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 965 | "template argument must be a complete class or an unbounded array" ); |
| 966 | }; |
| 967 | |
| 968 | /// @cond undocumented |
| 969 | template<typename _Tp, typename... _Args> |
| 970 | struct __is_constructible_impl |
| 971 | : public __bool_constant<__is_constructible(_Tp, _Args...)> |
| 972 | { }; |
| 973 | /// @endcond |
| 974 | |
| 975 | /// is_constructible |
| 976 | template<typename _Tp, typename... _Args> |
| 977 | struct is_constructible |
| 978 | : public __is_constructible_impl<_Tp, _Args...> |
| 979 | { |
| 980 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 981 | "template argument must be a complete class or an unbounded array" ); |
| 982 | }; |
| 983 | |
| 984 | /// is_default_constructible |
| 985 | template<typename _Tp> |
| 986 | struct is_default_constructible |
| 987 | : public __is_constructible_impl<_Tp>::type |
| 988 | { |
| 989 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 990 | "template argument must be a complete class or an unbounded array" ); |
| 991 | }; |
| 992 | |
| 993 | /// @cond undocumented |
| 994 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 995 | struct __is_copy_constructible_impl; |
| 996 | |
| 997 | template<typename _Tp> |
| 998 | struct __is_copy_constructible_impl<_Tp, false> |
| 999 | : public false_type { }; |
| 1000 | |
| 1001 | template<typename _Tp> |
| 1002 | struct __is_copy_constructible_impl<_Tp, true> |
| 1003 | : public __is_constructible_impl<_Tp, const _Tp&> |
| 1004 | { }; |
| 1005 | /// @endcond |
| 1006 | |
| 1007 | /// is_copy_constructible |
| 1008 | template<typename _Tp> |
| 1009 | struct is_copy_constructible |
| 1010 | : public __is_copy_constructible_impl<_Tp> |
| 1011 | { |
| 1012 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1013 | "template argument must be a complete class or an unbounded array" ); |
| 1014 | }; |
| 1015 | |
| 1016 | /// @cond undocumented |
| 1017 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1018 | struct __is_move_constructible_impl; |
| 1019 | |
| 1020 | template<typename _Tp> |
| 1021 | struct __is_move_constructible_impl<_Tp, false> |
| 1022 | : public false_type { }; |
| 1023 | |
| 1024 | template<typename _Tp> |
| 1025 | struct __is_move_constructible_impl<_Tp, true> |
| 1026 | : public __is_constructible_impl<_Tp, _Tp&&> |
| 1027 | { }; |
| 1028 | /// @endcond |
| 1029 | |
| 1030 | /// is_move_constructible |
| 1031 | template<typename _Tp> |
| 1032 | struct is_move_constructible |
| 1033 | : public __is_move_constructible_impl<_Tp> |
| 1034 | { |
| 1035 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1036 | "template argument must be a complete class or an unbounded array" ); |
| 1037 | }; |
| 1038 | |
| 1039 | /// @cond undocumented |
| 1040 | template<typename _Tp, typename... _Args> |
| 1041 | using __is_nothrow_constructible_impl |
| 1042 | = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>; |
| 1043 | /// @endcond |
| 1044 | |
| 1045 | /// is_nothrow_constructible |
| 1046 | template<typename _Tp, typename... _Args> |
| 1047 | struct is_nothrow_constructible |
| 1048 | : public __is_nothrow_constructible_impl<_Tp, _Args...>::type |
| 1049 | { |
| 1050 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1051 | "template argument must be a complete class or an unbounded array" ); |
| 1052 | }; |
| 1053 | |
| 1054 | /// is_nothrow_default_constructible |
| 1055 | template<typename _Tp> |
| 1056 | struct is_nothrow_default_constructible |
| 1057 | : public __bool_constant<__is_nothrow_constructible(_Tp)> |
| 1058 | { |
| 1059 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1060 | "template argument must be a complete class or an unbounded array" ); |
| 1061 | }; |
| 1062 | |
| 1063 | /// @cond undocumented |
| 1064 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1065 | struct __is_nothrow_copy_constructible_impl; |
| 1066 | |
| 1067 | template<typename _Tp> |
| 1068 | struct __is_nothrow_copy_constructible_impl<_Tp, false> |
| 1069 | : public false_type { }; |
| 1070 | |
| 1071 | template<typename _Tp> |
| 1072 | struct __is_nothrow_copy_constructible_impl<_Tp, true> |
| 1073 | : public __is_nothrow_constructible_impl<_Tp, const _Tp&> |
| 1074 | { }; |
| 1075 | /// @endcond |
| 1076 | |
| 1077 | /// is_nothrow_copy_constructible |
| 1078 | template<typename _Tp> |
| 1079 | struct is_nothrow_copy_constructible |
| 1080 | : public __is_nothrow_copy_constructible_impl<_Tp>::type |
| 1081 | { |
| 1082 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1083 | "template argument must be a complete class or an unbounded array" ); |
| 1084 | }; |
| 1085 | |
| 1086 | /// @cond undocumented |
| 1087 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1088 | struct __is_nothrow_move_constructible_impl; |
| 1089 | |
| 1090 | template<typename _Tp> |
| 1091 | struct __is_nothrow_move_constructible_impl<_Tp, false> |
| 1092 | : public false_type { }; |
| 1093 | |
| 1094 | template<typename _Tp> |
| 1095 | struct __is_nothrow_move_constructible_impl<_Tp, true> |
| 1096 | : public __is_nothrow_constructible_impl<_Tp, _Tp&&> |
| 1097 | { }; |
| 1098 | /// @endcond |
| 1099 | |
| 1100 | /// is_nothrow_move_constructible |
| 1101 | template<typename _Tp> |
| 1102 | struct is_nothrow_move_constructible |
| 1103 | : public __is_nothrow_move_constructible_impl<_Tp>::type |
| 1104 | { |
| 1105 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1106 | "template argument must be a complete class or an unbounded array" ); |
| 1107 | }; |
| 1108 | |
| 1109 | /// is_assignable |
| 1110 | template<typename _Tp, typename _Up> |
| 1111 | struct is_assignable |
| 1112 | : public __bool_constant<__is_assignable(_Tp, _Up)> |
| 1113 | { |
| 1114 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1115 | "template argument must be a complete class or an unbounded array" ); |
| 1116 | }; |
| 1117 | |
| 1118 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1119 | struct __is_copy_assignable_impl; |
| 1120 | |
| 1121 | template<typename _Tp> |
| 1122 | struct __is_copy_assignable_impl<_Tp, false> |
| 1123 | : public false_type { }; |
| 1124 | |
| 1125 | template<typename _Tp> |
| 1126 | struct __is_copy_assignable_impl<_Tp, true> |
| 1127 | : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> |
| 1128 | { }; |
| 1129 | |
| 1130 | /// is_copy_assignable |
| 1131 | template<typename _Tp> |
| 1132 | struct is_copy_assignable |
| 1133 | : public __is_copy_assignable_impl<_Tp>::type |
| 1134 | { |
| 1135 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1136 | "template argument must be a complete class or an unbounded array" ); |
| 1137 | }; |
| 1138 | |
| 1139 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1140 | struct __is_move_assignable_impl; |
| 1141 | |
| 1142 | template<typename _Tp> |
| 1143 | struct __is_move_assignable_impl<_Tp, false> |
| 1144 | : public false_type { }; |
| 1145 | |
| 1146 | template<typename _Tp> |
| 1147 | struct __is_move_assignable_impl<_Tp, true> |
| 1148 | : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> |
| 1149 | { }; |
| 1150 | |
| 1151 | /// is_move_assignable |
| 1152 | template<typename _Tp> |
| 1153 | struct is_move_assignable |
| 1154 | : public __is_move_assignable_impl<_Tp>::type |
| 1155 | { |
| 1156 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1157 | "template argument must be a complete class or an unbounded array" ); |
| 1158 | }; |
| 1159 | |
| 1160 | template<typename _Tp, typename _Up> |
| 1161 | using __is_nothrow_assignable_impl |
| 1162 | = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>; |
| 1163 | |
| 1164 | /// is_nothrow_assignable |
| 1165 | template<typename _Tp, typename _Up> |
| 1166 | struct is_nothrow_assignable |
| 1167 | : public __is_nothrow_assignable_impl<_Tp, _Up> |
| 1168 | { |
| 1169 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1170 | "template argument must be a complete class or an unbounded array" ); |
| 1171 | }; |
| 1172 | |
| 1173 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1174 | struct __is_nt_copy_assignable_impl; |
| 1175 | |
| 1176 | template<typename _Tp> |
| 1177 | struct __is_nt_copy_assignable_impl<_Tp, false> |
| 1178 | : public false_type { }; |
| 1179 | |
| 1180 | template<typename _Tp> |
| 1181 | struct __is_nt_copy_assignable_impl<_Tp, true> |
| 1182 | : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> |
| 1183 | { }; |
| 1184 | |
| 1185 | /// is_nothrow_copy_assignable |
| 1186 | template<typename _Tp> |
| 1187 | struct is_nothrow_copy_assignable |
| 1188 | : public __is_nt_copy_assignable_impl<_Tp> |
| 1189 | { |
| 1190 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1191 | "template argument must be a complete class or an unbounded array" ); |
| 1192 | }; |
| 1193 | |
| 1194 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1195 | struct __is_nt_move_assignable_impl; |
| 1196 | |
| 1197 | template<typename _Tp> |
| 1198 | struct __is_nt_move_assignable_impl<_Tp, false> |
| 1199 | : public false_type { }; |
| 1200 | |
| 1201 | template<typename _Tp> |
| 1202 | struct __is_nt_move_assignable_impl<_Tp, true> |
| 1203 | : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> |
| 1204 | { }; |
| 1205 | |
| 1206 | /// is_nothrow_move_assignable |
| 1207 | template<typename _Tp> |
| 1208 | struct is_nothrow_move_assignable |
| 1209 | : public __is_nt_move_assignable_impl<_Tp> |
| 1210 | { |
| 1211 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1212 | "template argument must be a complete class or an unbounded array" ); |
| 1213 | }; |
| 1214 | |
| 1215 | /// is_trivially_constructible |
| 1216 | template<typename _Tp, typename... _Args> |
| 1217 | struct is_trivially_constructible |
| 1218 | : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> |
| 1219 | { |
| 1220 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1221 | "template argument must be a complete class or an unbounded array" ); |
| 1222 | }; |
| 1223 | |
| 1224 | /// is_trivially_default_constructible |
| 1225 | template<typename _Tp> |
| 1226 | struct is_trivially_default_constructible |
| 1227 | : public __bool_constant<__is_trivially_constructible(_Tp)> |
| 1228 | { |
| 1229 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1230 | "template argument must be a complete class or an unbounded array" ); |
| 1231 | }; |
| 1232 | |
| 1233 | struct __do_is_implicitly_default_constructible_impl |
| 1234 | { |
| 1235 | template <typename _Tp> |
| 1236 | static void __helper(const _Tp&); |
| 1237 | |
| 1238 | template <typename _Tp> |
| 1239 | static true_type __test(const _Tp&, |
| 1240 | decltype(__helper<const _Tp&>({}))* = 0); |
| 1241 | |
| 1242 | static false_type __test(...); |
| 1243 | }; |
| 1244 | |
| 1245 | template<typename _Tp> |
| 1246 | struct __is_implicitly_default_constructible_impl |
| 1247 | : public __do_is_implicitly_default_constructible_impl |
| 1248 | { |
| 1249 | typedef decltype(__test(declval<_Tp>())) type; |
| 1250 | }; |
| 1251 | |
| 1252 | template<typename _Tp> |
| 1253 | struct __is_implicitly_default_constructible_safe |
| 1254 | : public __is_implicitly_default_constructible_impl<_Tp>::type |
| 1255 | { }; |
| 1256 | |
| 1257 | template <typename _Tp> |
| 1258 | struct __is_implicitly_default_constructible |
| 1259 | : public __and_<__is_constructible_impl<_Tp>, |
| 1260 | __is_implicitly_default_constructible_safe<_Tp>> |
| 1261 | { }; |
| 1262 | |
| 1263 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1264 | struct __is_trivially_copy_constructible_impl; |
| 1265 | |
| 1266 | template<typename _Tp> |
| 1267 | struct __is_trivially_copy_constructible_impl<_Tp, false> |
| 1268 | : public false_type { }; |
| 1269 | |
| 1270 | template<typename _Tp> |
| 1271 | struct __is_trivially_copy_constructible_impl<_Tp, true> |
| 1272 | : public __and_<__is_copy_constructible_impl<_Tp>, |
| 1273 | integral_constant<bool, |
| 1274 | __is_trivially_constructible(_Tp, const _Tp&)>> |
| 1275 | { }; |
| 1276 | |
| 1277 | /// is_trivially_copy_constructible |
| 1278 | template<typename _Tp> |
| 1279 | struct is_trivially_copy_constructible |
| 1280 | : public __is_trivially_copy_constructible_impl<_Tp> |
| 1281 | { |
| 1282 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1283 | "template argument must be a complete class or an unbounded array" ); |
| 1284 | }; |
| 1285 | |
| 1286 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1287 | struct __is_trivially_move_constructible_impl; |
| 1288 | |
| 1289 | template<typename _Tp> |
| 1290 | struct __is_trivially_move_constructible_impl<_Tp, false> |
| 1291 | : public false_type { }; |
| 1292 | |
| 1293 | template<typename _Tp> |
| 1294 | struct __is_trivially_move_constructible_impl<_Tp, true> |
| 1295 | : public __and_<__is_move_constructible_impl<_Tp>, |
| 1296 | integral_constant<bool, |
| 1297 | __is_trivially_constructible(_Tp, _Tp&&)>> |
| 1298 | { }; |
| 1299 | |
| 1300 | /// is_trivially_move_constructible |
| 1301 | template<typename _Tp> |
| 1302 | struct is_trivially_move_constructible |
| 1303 | : public __is_trivially_move_constructible_impl<_Tp> |
| 1304 | { |
| 1305 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1306 | "template argument must be a complete class or an unbounded array" ); |
| 1307 | }; |
| 1308 | |
| 1309 | /// is_trivially_assignable |
| 1310 | template<typename _Tp, typename _Up> |
| 1311 | struct is_trivially_assignable |
| 1312 | : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> |
| 1313 | { |
| 1314 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1315 | "template argument must be a complete class or an unbounded array" ); |
| 1316 | }; |
| 1317 | |
| 1318 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1319 | struct __is_trivially_copy_assignable_impl; |
| 1320 | |
| 1321 | template<typename _Tp> |
| 1322 | struct __is_trivially_copy_assignable_impl<_Tp, false> |
| 1323 | : public false_type { }; |
| 1324 | |
| 1325 | template<typename _Tp> |
| 1326 | struct __is_trivially_copy_assignable_impl<_Tp, true> |
| 1327 | : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> |
| 1328 | { }; |
| 1329 | |
| 1330 | /// is_trivially_copy_assignable |
| 1331 | template<typename _Tp> |
| 1332 | struct is_trivially_copy_assignable |
| 1333 | : public __is_trivially_copy_assignable_impl<_Tp> |
| 1334 | { |
| 1335 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1336 | "template argument must be a complete class or an unbounded array" ); |
| 1337 | }; |
| 1338 | |
| 1339 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1340 | struct __is_trivially_move_assignable_impl; |
| 1341 | |
| 1342 | template<typename _Tp> |
| 1343 | struct __is_trivially_move_assignable_impl<_Tp, false> |
| 1344 | : public false_type { }; |
| 1345 | |
| 1346 | template<typename _Tp> |
| 1347 | struct __is_trivially_move_assignable_impl<_Tp, true> |
| 1348 | : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> |
| 1349 | { }; |
| 1350 | |
| 1351 | /// is_trivially_move_assignable |
| 1352 | template<typename _Tp> |
| 1353 | struct is_trivially_move_assignable |
| 1354 | : public __is_trivially_move_assignable_impl<_Tp> |
| 1355 | { |
| 1356 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1357 | "template argument must be a complete class or an unbounded array" ); |
| 1358 | }; |
| 1359 | |
| 1360 | /// is_trivially_destructible |
| 1361 | template<typename _Tp> |
| 1362 | struct is_trivially_destructible |
| 1363 | : public __and_<__is_destructible_safe<_Tp>, |
| 1364 | __bool_constant<__has_trivial_destructor(_Tp)>> |
| 1365 | { |
| 1366 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1367 | "template argument must be a complete class or an unbounded array" ); |
| 1368 | }; |
| 1369 | |
| 1370 | |
| 1371 | /// has_virtual_destructor |
| 1372 | template<typename _Tp> |
| 1373 | struct has_virtual_destructor |
| 1374 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> |
| 1375 | { |
| 1376 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1377 | "template argument must be a complete class or an unbounded array" ); |
| 1378 | }; |
| 1379 | |
| 1380 | |
| 1381 | // type property queries. |
| 1382 | |
| 1383 | /// alignment_of |
| 1384 | template<typename _Tp> |
| 1385 | struct alignment_of |
| 1386 | : public integral_constant<std::size_t, alignof(_Tp)> |
| 1387 | { |
| 1388 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 1389 | "template argument must be a complete class or an unbounded array" ); |
| 1390 | }; |
| 1391 | |
| 1392 | /// rank |
| 1393 | template<typename> |
| 1394 | struct rank |
| 1395 | : public integral_constant<std::size_t, 0> { }; |
| 1396 | |
| 1397 | template<typename _Tp, std::size_t _Size> |
| 1398 | struct rank<_Tp[_Size]> |
| 1399 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; |
| 1400 | |
| 1401 | template<typename _Tp> |
| 1402 | struct rank<_Tp[]> |
| 1403 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; |
| 1404 | |
| 1405 | /// extent |
| 1406 | template<typename, unsigned _Uint> |
| 1407 | struct extent |
| 1408 | : public integral_constant<std::size_t, 0> { }; |
| 1409 | |
| 1410 | template<typename _Tp, unsigned _Uint, std::size_t _Size> |
| 1411 | struct extent<_Tp[_Size], _Uint> |
| 1412 | : public integral_constant<std::size_t, |
| 1413 | _Uint == 0 ? _Size : extent<_Tp, |
| 1414 | _Uint - 1>::value> |
| 1415 | { }; |
| 1416 | |
| 1417 | template<typename _Tp, unsigned _Uint> |
| 1418 | struct extent<_Tp[], _Uint> |
| 1419 | : public integral_constant<std::size_t, |
| 1420 | _Uint == 0 ? 0 : extent<_Tp, |
| 1421 | _Uint - 1>::value> |
| 1422 | { }; |
| 1423 | |
| 1424 | |
| 1425 | // Type relations. |
| 1426 | |
| 1427 | /// is_same |
| 1428 | template<typename _Tp, typename _Up> |
| 1429 | struct is_same |
| 1430 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME |
| 1431 | : public integral_constant<bool, __is_same(_Tp, _Up)> |
| 1432 | #else |
| 1433 | : public false_type |
| 1434 | #endif |
| 1435 | { }; |
| 1436 | |
| 1437 | #ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME |
| 1438 | template<typename _Tp> |
| 1439 | struct is_same<_Tp, _Tp> |
| 1440 | : public true_type |
| 1441 | { }; |
| 1442 | #endif |
| 1443 | |
| 1444 | /// is_base_of |
| 1445 | template<typename _Base, typename _Derived> |
| 1446 | struct is_base_of |
| 1447 | : public integral_constant<bool, __is_base_of(_Base, _Derived)> |
| 1448 | { }; |
| 1449 | |
| 1450 | template<typename _From, typename _To, |
| 1451 | bool = __or_<is_void<_From>, is_function<_To>, |
| 1452 | is_array<_To>>::value> |
| 1453 | struct __is_convertible_helper |
| 1454 | { |
| 1455 | typedef typename is_void<_To>::type type; |
| 1456 | }; |
| 1457 | |
| 1458 | #pragma GCC diagnostic push |
| 1459 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
| 1460 | template<typename _From, typename _To> |
| 1461 | class __is_convertible_helper<_From, _To, false> |
| 1462 | { |
| 1463 | template<typename _To1> |
| 1464 | static void __test_aux(_To1) noexcept; |
| 1465 | |
| 1466 | template<typename _From1, typename _To1, |
| 1467 | typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> |
| 1468 | static true_type |
| 1469 | __test(int); |
| 1470 | |
| 1471 | template<typename, typename> |
| 1472 | static false_type |
| 1473 | __test(...); |
| 1474 | |
| 1475 | public: |
| 1476 | typedef decltype(__test<_From, _To>(0)) type; |
| 1477 | }; |
| 1478 | #pragma GCC diagnostic pop |
| 1479 | |
| 1480 | /// is_convertible |
| 1481 | template<typename _From, typename _To> |
| 1482 | struct is_convertible |
| 1483 | : public __is_convertible_helper<_From, _To>::type |
| 1484 | { }; |
| 1485 | |
| 1486 | // helper trait for unique_ptr<T[]>, shared_ptr<T[]>, and span<T, N> |
| 1487 | template<typename _ToElementType, typename _FromElementType> |
| 1488 | using __is_array_convertible |
| 1489 | = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; |
| 1490 | |
| 1491 | template<typename _From, typename _To, |
| 1492 | bool = __or_<is_void<_From>, is_function<_To>, |
| 1493 | is_array<_To>>::value> |
| 1494 | struct __is_nt_convertible_helper |
| 1495 | : is_void<_To> |
| 1496 | { }; |
| 1497 | |
| 1498 | #pragma GCC diagnostic push |
| 1499 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
| 1500 | template<typename _From, typename _To> |
| 1501 | class __is_nt_convertible_helper<_From, _To, false> |
| 1502 | { |
| 1503 | template<typename _To1> |
| 1504 | static void __test_aux(_To1) noexcept; |
| 1505 | |
| 1506 | template<typename _From1, typename _To1> |
| 1507 | static |
| 1508 | __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))> |
| 1509 | __test(int); |
| 1510 | |
| 1511 | template<typename, typename> |
| 1512 | static false_type |
| 1513 | __test(...); |
| 1514 | |
| 1515 | public: |
| 1516 | using type = decltype(__test<_From, _To>(0)); |
| 1517 | }; |
| 1518 | #pragma GCC diagnostic pop |
| 1519 | |
| 1520 | // is_nothrow_convertible for C++11 |
| 1521 | template<typename _From, typename _To> |
| 1522 | struct __is_nothrow_convertible |
| 1523 | : public __is_nt_convertible_helper<_From, _To>::type |
| 1524 | { }; |
| 1525 | |
| 1526 | #if __cplusplus > 201703L |
| 1527 | #define __cpp_lib_is_nothrow_convertible 201806L |
| 1528 | /// is_nothrow_convertible |
| 1529 | template<typename _From, typename _To> |
| 1530 | struct is_nothrow_convertible |
| 1531 | : public __is_nt_convertible_helper<_From, _To>::type |
| 1532 | { }; |
| 1533 | |
| 1534 | /// is_nothrow_convertible_v |
| 1535 | template<typename _From, typename _To> |
| 1536 | inline constexpr bool is_nothrow_convertible_v |
| 1537 | = is_nothrow_convertible<_From, _To>::value; |
| 1538 | #endif // C++2a |
| 1539 | |
| 1540 | // Const-volatile modifications. |
| 1541 | |
| 1542 | /// remove_const |
| 1543 | template<typename _Tp> |
| 1544 | struct remove_const |
| 1545 | { typedef _Tp type; }; |
| 1546 | |
| 1547 | template<typename _Tp> |
| 1548 | struct remove_const<_Tp const> |
| 1549 | { typedef _Tp type; }; |
| 1550 | |
| 1551 | /// remove_volatile |
| 1552 | template<typename _Tp> |
| 1553 | struct remove_volatile |
| 1554 | { typedef _Tp type; }; |
| 1555 | |
| 1556 | template<typename _Tp> |
| 1557 | struct remove_volatile<_Tp volatile> |
| 1558 | { typedef _Tp type; }; |
| 1559 | |
| 1560 | /// remove_cv |
| 1561 | template<typename _Tp> |
| 1562 | struct remove_cv |
| 1563 | { using type = _Tp; }; |
| 1564 | |
| 1565 | template<typename _Tp> |
| 1566 | struct remove_cv<const _Tp> |
| 1567 | { using type = _Tp; }; |
| 1568 | |
| 1569 | template<typename _Tp> |
| 1570 | struct remove_cv<volatile _Tp> |
| 1571 | { using type = _Tp; }; |
| 1572 | |
| 1573 | template<typename _Tp> |
| 1574 | struct remove_cv<const volatile _Tp> |
| 1575 | { using type = _Tp; }; |
| 1576 | |
| 1577 | /// add_const |
| 1578 | template<typename _Tp> |
| 1579 | struct add_const |
| 1580 | { typedef _Tp const type; }; |
| 1581 | |
| 1582 | /// add_volatile |
| 1583 | template<typename _Tp> |
| 1584 | struct add_volatile |
| 1585 | { typedef _Tp volatile type; }; |
| 1586 | |
| 1587 | /// add_cv |
| 1588 | template<typename _Tp> |
| 1589 | struct add_cv |
| 1590 | { |
| 1591 | typedef typename |
| 1592 | add_const<typename add_volatile<_Tp>::type>::type type; |
| 1593 | }; |
| 1594 | |
| 1595 | #if __cplusplus > 201103L |
| 1596 | |
| 1597 | #define __cpp_lib_transformation_trait_aliases 201304L |
| 1598 | |
| 1599 | /// Alias template for remove_const |
| 1600 | template<typename _Tp> |
| 1601 | using remove_const_t = typename remove_const<_Tp>::type; |
| 1602 | |
| 1603 | /// Alias template for remove_volatile |
| 1604 | template<typename _Tp> |
| 1605 | using remove_volatile_t = typename remove_volatile<_Tp>::type; |
| 1606 | |
| 1607 | /// Alias template for remove_cv |
| 1608 | template<typename _Tp> |
| 1609 | using remove_cv_t = typename remove_cv<_Tp>::type; |
| 1610 | |
| 1611 | /// Alias template for add_const |
| 1612 | template<typename _Tp> |
| 1613 | using add_const_t = typename add_const<_Tp>::type; |
| 1614 | |
| 1615 | /// Alias template for add_volatile |
| 1616 | template<typename _Tp> |
| 1617 | using add_volatile_t = typename add_volatile<_Tp>::type; |
| 1618 | |
| 1619 | /// Alias template for add_cv |
| 1620 | template<typename _Tp> |
| 1621 | using add_cv_t = typename add_cv<_Tp>::type; |
| 1622 | #endif |
| 1623 | |
| 1624 | // Reference transformations. |
| 1625 | |
| 1626 | /// remove_reference |
| 1627 | template<typename _Tp> |
| 1628 | struct remove_reference |
| 1629 | { typedef _Tp type; }; |
| 1630 | |
| 1631 | template<typename _Tp> |
| 1632 | struct remove_reference<_Tp&> |
| 1633 | { typedef _Tp type; }; |
| 1634 | |
| 1635 | template<typename _Tp> |
| 1636 | struct remove_reference<_Tp&&> |
| 1637 | { typedef _Tp type; }; |
| 1638 | |
| 1639 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1640 | struct __add_lvalue_reference_helper |
| 1641 | { typedef _Tp type; }; |
| 1642 | |
| 1643 | template<typename _Tp> |
| 1644 | struct __add_lvalue_reference_helper<_Tp, true> |
| 1645 | { typedef _Tp& type; }; |
| 1646 | |
| 1647 | /// add_lvalue_reference |
| 1648 | template<typename _Tp> |
| 1649 | struct add_lvalue_reference |
| 1650 | : public __add_lvalue_reference_helper<_Tp> |
| 1651 | { }; |
| 1652 | |
| 1653 | template<typename _Tp, bool = __is_referenceable<_Tp>::value> |
| 1654 | struct __add_rvalue_reference_helper |
| 1655 | { typedef _Tp type; }; |
| 1656 | |
| 1657 | template<typename _Tp> |
| 1658 | struct __add_rvalue_reference_helper<_Tp, true> |
| 1659 | { typedef _Tp&& type; }; |
| 1660 | |
| 1661 | /// add_rvalue_reference |
| 1662 | template<typename _Tp> |
| 1663 | struct add_rvalue_reference |
| 1664 | : public __add_rvalue_reference_helper<_Tp> |
| 1665 | { }; |
| 1666 | |
| 1667 | #if __cplusplus > 201103L |
| 1668 | /// Alias template for remove_reference |
| 1669 | template<typename _Tp> |
| 1670 | using remove_reference_t = typename remove_reference<_Tp>::type; |
| 1671 | |
| 1672 | /// Alias template for add_lvalue_reference |
| 1673 | template<typename _Tp> |
| 1674 | using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; |
| 1675 | |
| 1676 | /// Alias template for add_rvalue_reference |
| 1677 | template<typename _Tp> |
| 1678 | using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; |
| 1679 | #endif |
| 1680 | |
| 1681 | // Sign modifications. |
| 1682 | |
| 1683 | /// @cond undocumented |
| 1684 | |
| 1685 | // Utility for constructing identically cv-qualified types. |
| 1686 | template<typename _Unqualified, bool _IsConst, bool _IsVol> |
| 1687 | struct __cv_selector; |
| 1688 | |
| 1689 | template<typename _Unqualified> |
| 1690 | struct __cv_selector<_Unqualified, false, false> |
| 1691 | { typedef _Unqualified __type; }; |
| 1692 | |
| 1693 | template<typename _Unqualified> |
| 1694 | struct __cv_selector<_Unqualified, false, true> |
| 1695 | { typedef volatile _Unqualified __type; }; |
| 1696 | |
| 1697 | template<typename _Unqualified> |
| 1698 | struct __cv_selector<_Unqualified, true, false> |
| 1699 | { typedef const _Unqualified __type; }; |
| 1700 | |
| 1701 | template<typename _Unqualified> |
| 1702 | struct __cv_selector<_Unqualified, true, true> |
| 1703 | { typedef const volatile _Unqualified __type; }; |
| 1704 | |
| 1705 | template<typename _Qualified, typename _Unqualified, |
| 1706 | bool _IsConst = is_const<_Qualified>::value, |
| 1707 | bool _IsVol = is_volatile<_Qualified>::value> |
| 1708 | class __match_cv_qualifiers |
| 1709 | { |
| 1710 | typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; |
| 1711 | |
| 1712 | public: |
| 1713 | typedef typename __match::__type __type; |
| 1714 | }; |
| 1715 | |
| 1716 | // Utility for finding the unsigned versions of signed integral types. |
| 1717 | template<typename _Tp> |
| 1718 | struct __make_unsigned |
| 1719 | { typedef _Tp __type; }; |
| 1720 | |
| 1721 | template<> |
| 1722 | struct __make_unsigned<char> |
| 1723 | { typedef unsigned char __type; }; |
| 1724 | |
| 1725 | template<> |
| 1726 | struct __make_unsigned<signed char> |
| 1727 | { typedef unsigned char __type; }; |
| 1728 | |
| 1729 | template<> |
| 1730 | struct __make_unsigned<short> |
| 1731 | { typedef unsigned short __type; }; |
| 1732 | |
| 1733 | template<> |
| 1734 | struct __make_unsigned<int> |
| 1735 | { typedef unsigned int __type; }; |
| 1736 | |
| 1737 | template<> |
| 1738 | struct __make_unsigned<long> |
| 1739 | { typedef unsigned long __type; }; |
| 1740 | |
| 1741 | template<> |
| 1742 | struct __make_unsigned<long long> |
| 1743 | { typedef unsigned long long __type; }; |
| 1744 | |
| 1745 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
| 1746 | __extension__ |
| 1747 | template<> |
| 1748 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> |
| 1749 | { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; |
| 1750 | #endif |
| 1751 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
| 1752 | __extension__ |
| 1753 | template<> |
| 1754 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> |
| 1755 | { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; |
| 1756 | #endif |
| 1757 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
| 1758 | __extension__ |
| 1759 | template<> |
| 1760 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> |
| 1761 | { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; |
| 1762 | #endif |
| 1763 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
| 1764 | __extension__ |
| 1765 | template<> |
| 1766 | struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> |
| 1767 | { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; |
| 1768 | #endif |
| 1769 | |
| 1770 | // Select between integral and enum: not possible to be both. |
| 1771 | template<typename _Tp, |
| 1772 | bool _IsInt = is_integral<_Tp>::value, |
| 1773 | bool _IsEnum = is_enum<_Tp>::value> |
| 1774 | class __make_unsigned_selector; |
| 1775 | |
| 1776 | template<typename _Tp> |
| 1777 | class __make_unsigned_selector<_Tp, true, false> |
| 1778 | { |
| 1779 | using __unsigned_type |
| 1780 | = typename __make_unsigned<__remove_cv_t<_Tp>>::__type; |
| 1781 | |
| 1782 | public: |
| 1783 | using __type |
| 1784 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; |
| 1785 | }; |
| 1786 | |
| 1787 | class __make_unsigned_selector_base |
| 1788 | { |
| 1789 | protected: |
| 1790 | template<typename...> struct _List { }; |
| 1791 | |
| 1792 | template<typename _Tp, typename... _Up> |
| 1793 | struct _List<_Tp, _Up...> : _List<_Up...> |
| 1794 | { static constexpr size_t __size = sizeof(_Tp); }; |
| 1795 | |
| 1796 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> |
| 1797 | struct __select; |
| 1798 | |
| 1799 | template<size_t _Sz, typename _Uint, typename... _UInts> |
| 1800 | struct __select<_Sz, _List<_Uint, _UInts...>, true> |
| 1801 | { using __type = _Uint; }; |
| 1802 | |
| 1803 | template<size_t _Sz, typename _Uint, typename... _UInts> |
| 1804 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
| 1805 | : __select<_Sz, _List<_UInts...>> |
| 1806 | { }; |
| 1807 | }; |
| 1808 | |
| 1809 | // Choose unsigned integer type with the smallest rank and same size as _Tp |
| 1810 | template<typename _Tp> |
| 1811 | class __make_unsigned_selector<_Tp, false, true> |
| 1812 | : __make_unsigned_selector_base |
| 1813 | { |
| 1814 | // With -fshort-enums, an enum may be as small as a char. |
| 1815 | using _UInts = _List<unsigned char, unsigned short, unsigned int, |
| 1816 | unsigned long, unsigned long long>; |
| 1817 | |
| 1818 | using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; |
| 1819 | |
| 1820 | public: |
| 1821 | using __type |
| 1822 | = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; |
| 1823 | }; |
| 1824 | |
| 1825 | // wchar_t, char8_t, char16_t and char32_t are integral types but are |
| 1826 | // neither signed integer types nor unsigned integer types, so must be |
| 1827 | // transformed to the unsigned integer type with the smallest rank. |
| 1828 | // Use the partial specialization for enumeration types to do that. |
| 1829 | template<> |
| 1830 | struct __make_unsigned<wchar_t> |
| 1831 | { |
| 1832 | using __type |
| 1833 | = typename __make_unsigned_selector<wchar_t, false, true>::__type; |
| 1834 | }; |
| 1835 | |
| 1836 | #ifdef _GLIBCXX_USE_CHAR8_T |
| 1837 | template<> |
| 1838 | struct __make_unsigned<char8_t> |
| 1839 | { |
| 1840 | using __type |
| 1841 | = typename __make_unsigned_selector<char8_t, false, true>::__type; |
| 1842 | }; |
| 1843 | #endif |
| 1844 | |
| 1845 | template<> |
| 1846 | struct __make_unsigned<char16_t> |
| 1847 | { |
| 1848 | using __type |
| 1849 | = typename __make_unsigned_selector<char16_t, false, true>::__type; |
| 1850 | }; |
| 1851 | |
| 1852 | template<> |
| 1853 | struct __make_unsigned<char32_t> |
| 1854 | { |
| 1855 | using __type |
| 1856 | = typename __make_unsigned_selector<char32_t, false, true>::__type; |
| 1857 | }; |
| 1858 | /// @endcond |
| 1859 | |
| 1860 | // Given an integral/enum type, return the corresponding unsigned |
| 1861 | // integer type. |
| 1862 | // Primary template. |
| 1863 | /// make_unsigned |
| 1864 | template<typename _Tp> |
| 1865 | struct make_unsigned |
| 1866 | { typedef typename __make_unsigned_selector<_Tp>::__type type; }; |
| 1867 | |
| 1868 | // Integral, but don't define. |
| 1869 | template<> |
| 1870 | struct make_unsigned<bool>; |
| 1871 | |
| 1872 | /// @cond undocumented |
| 1873 | |
| 1874 | // Utility for finding the signed versions of unsigned integral types. |
| 1875 | template<typename _Tp> |
| 1876 | struct __make_signed |
| 1877 | { typedef _Tp __type; }; |
| 1878 | |
| 1879 | template<> |
| 1880 | struct __make_signed<char> |
| 1881 | { typedef signed char __type; }; |
| 1882 | |
| 1883 | template<> |
| 1884 | struct __make_signed<unsigned char> |
| 1885 | { typedef signed char __type; }; |
| 1886 | |
| 1887 | template<> |
| 1888 | struct __make_signed<unsigned short> |
| 1889 | { typedef signed short __type; }; |
| 1890 | |
| 1891 | template<> |
| 1892 | struct __make_signed<unsigned int> |
| 1893 | { typedef signed int __type; }; |
| 1894 | |
| 1895 | template<> |
| 1896 | struct __make_signed<unsigned long> |
| 1897 | { typedef signed long __type; }; |
| 1898 | |
| 1899 | template<> |
| 1900 | struct __make_signed<unsigned long long> |
| 1901 | { typedef signed long long __type; }; |
| 1902 | |
| 1903 | #if defined(__GLIBCXX_TYPE_INT_N_0) |
| 1904 | __extension__ |
| 1905 | template<> |
| 1906 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> |
| 1907 | { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; |
| 1908 | #endif |
| 1909 | #if defined(__GLIBCXX_TYPE_INT_N_1) |
| 1910 | __extension__ |
| 1911 | template<> |
| 1912 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> |
| 1913 | { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; |
| 1914 | #endif |
| 1915 | #if defined(__GLIBCXX_TYPE_INT_N_2) |
| 1916 | __extension__ |
| 1917 | template<> |
| 1918 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> |
| 1919 | { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; |
| 1920 | #endif |
| 1921 | #if defined(__GLIBCXX_TYPE_INT_N_3) |
| 1922 | __extension__ |
| 1923 | template<> |
| 1924 | struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> |
| 1925 | { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; |
| 1926 | #endif |
| 1927 | |
| 1928 | // Select between integral and enum: not possible to be both. |
| 1929 | template<typename _Tp, |
| 1930 | bool _IsInt = is_integral<_Tp>::value, |
| 1931 | bool _IsEnum = is_enum<_Tp>::value> |
| 1932 | class __make_signed_selector; |
| 1933 | |
| 1934 | template<typename _Tp> |
| 1935 | class __make_signed_selector<_Tp, true, false> |
| 1936 | { |
| 1937 | using __signed_type |
| 1938 | = typename __make_signed<__remove_cv_t<_Tp>>::__type; |
| 1939 | |
| 1940 | public: |
| 1941 | using __type |
| 1942 | = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; |
| 1943 | }; |
| 1944 | |
| 1945 | // Choose signed integer type with the smallest rank and same size as _Tp |
| 1946 | template<typename _Tp> |
| 1947 | class __make_signed_selector<_Tp, false, true> |
| 1948 | { |
| 1949 | typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; |
| 1950 | |
| 1951 | public: |
| 1952 | typedef typename __make_signed_selector<__unsigned_type>::__type __type; |
| 1953 | }; |
| 1954 | |
| 1955 | // wchar_t, char16_t and char32_t are integral types but are neither |
| 1956 | // signed integer types nor unsigned integer types, so must be |
| 1957 | // transformed to the signed integer type with the smallest rank. |
| 1958 | // Use the partial specialization for enumeration types to do that. |
| 1959 | template<> |
| 1960 | struct __make_signed<wchar_t> |
| 1961 | { |
| 1962 | using __type |
| 1963 | = typename __make_signed_selector<wchar_t, false, true>::__type; |
| 1964 | }; |
| 1965 | |
| 1966 | #if defined(_GLIBCXX_USE_CHAR8_T) |
| 1967 | template<> |
| 1968 | struct __make_signed<char8_t> |
| 1969 | { |
| 1970 | using __type |
| 1971 | = typename __make_signed_selector<char8_t, false, true>::__type; |
| 1972 | }; |
| 1973 | #endif |
| 1974 | |
| 1975 | template<> |
| 1976 | struct __make_signed<char16_t> |
| 1977 | { |
| 1978 | using __type |
| 1979 | = typename __make_signed_selector<char16_t, false, true>::__type; |
| 1980 | }; |
| 1981 | |
| 1982 | template<> |
| 1983 | struct __make_signed<char32_t> |
| 1984 | { |
| 1985 | using __type |
| 1986 | = typename __make_signed_selector<char32_t, false, true>::__type; |
| 1987 | }; |
| 1988 | /// @endcond |
| 1989 | |
| 1990 | // Given an integral/enum type, return the corresponding signed |
| 1991 | // integer type. |
| 1992 | // Primary template. |
| 1993 | /// make_signed |
| 1994 | template<typename _Tp> |
| 1995 | struct make_signed |
| 1996 | { typedef typename __make_signed_selector<_Tp>::__type type; }; |
| 1997 | |
| 1998 | // Integral, but don't define. |
| 1999 | template<> |
| 2000 | struct make_signed<bool>; |
| 2001 | |
| 2002 | #if __cplusplus > 201103L |
| 2003 | /// Alias template for make_signed |
| 2004 | template<typename _Tp> |
| 2005 | using make_signed_t = typename make_signed<_Tp>::type; |
| 2006 | |
| 2007 | /// Alias template for make_unsigned |
| 2008 | template<typename _Tp> |
| 2009 | using make_unsigned_t = typename make_unsigned<_Tp>::type; |
| 2010 | #endif |
| 2011 | |
| 2012 | // Array modifications. |
| 2013 | |
| 2014 | /// remove_extent |
| 2015 | template<typename _Tp> |
| 2016 | struct remove_extent |
| 2017 | { typedef _Tp type; }; |
| 2018 | |
| 2019 | template<typename _Tp, std::size_t _Size> |
| 2020 | struct remove_extent<_Tp[_Size]> |
| 2021 | { typedef _Tp type; }; |
| 2022 | |
| 2023 | template<typename _Tp> |
| 2024 | struct remove_extent<_Tp[]> |
| 2025 | { typedef _Tp type; }; |
| 2026 | |
| 2027 | /// remove_all_extents |
| 2028 | template<typename _Tp> |
| 2029 | struct remove_all_extents |
| 2030 | { typedef _Tp type; }; |
| 2031 | |
| 2032 | template<typename _Tp, std::size_t _Size> |
| 2033 | struct remove_all_extents<_Tp[_Size]> |
| 2034 | { typedef typename remove_all_extents<_Tp>::type type; }; |
| 2035 | |
| 2036 | template<typename _Tp> |
| 2037 | struct remove_all_extents<_Tp[]> |
| 2038 | { typedef typename remove_all_extents<_Tp>::type type; }; |
| 2039 | |
| 2040 | #if __cplusplus > 201103L |
| 2041 | /// Alias template for remove_extent |
| 2042 | template<typename _Tp> |
| 2043 | using remove_extent_t = typename remove_extent<_Tp>::type; |
| 2044 | |
| 2045 | /// Alias template for remove_all_extents |
| 2046 | template<typename _Tp> |
| 2047 | using remove_all_extents_t = typename remove_all_extents<_Tp>::type; |
| 2048 | #endif |
| 2049 | |
| 2050 | // Pointer modifications. |
| 2051 | |
| 2052 | template<typename _Tp, typename> |
| 2053 | struct __remove_pointer_helper |
| 2054 | { typedef _Tp type; }; |
| 2055 | |
| 2056 | template<typename _Tp, typename _Up> |
| 2057 | struct __remove_pointer_helper<_Tp, _Up*> |
| 2058 | { typedef _Up type; }; |
| 2059 | |
| 2060 | /// remove_pointer |
| 2061 | template<typename _Tp> |
| 2062 | struct remove_pointer |
| 2063 | : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>> |
| 2064 | { }; |
| 2065 | |
| 2066 | template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, |
| 2067 | is_void<_Tp>>::value> |
| 2068 | struct __add_pointer_helper |
| 2069 | { typedef _Tp type; }; |
| 2070 | |
| 2071 | template<typename _Tp> |
| 2072 | struct __add_pointer_helper<_Tp, true> |
| 2073 | { typedef typename remove_reference<_Tp>::type* type; }; |
| 2074 | |
| 2075 | /// add_pointer |
| 2076 | template<typename _Tp> |
| 2077 | struct add_pointer |
| 2078 | : public __add_pointer_helper<_Tp> |
| 2079 | { }; |
| 2080 | |
| 2081 | #if __cplusplus > 201103L |
| 2082 | /// Alias template for remove_pointer |
| 2083 | template<typename _Tp> |
| 2084 | using remove_pointer_t = typename remove_pointer<_Tp>::type; |
| 2085 | |
| 2086 | /// Alias template for add_pointer |
| 2087 | template<typename _Tp> |
| 2088 | using add_pointer_t = typename add_pointer<_Tp>::type; |
| 2089 | #endif |
| 2090 | |
| 2091 | template<std::size_t _Len> |
| 2092 | struct __aligned_storage_msa |
| 2093 | { |
| 2094 | union __type |
| 2095 | { |
| 2096 | unsigned char __data[_Len]; |
| 2097 | struct __attribute__((__aligned__)) { } __align; |
| 2098 | }; |
| 2099 | }; |
| 2100 | |
| 2101 | /** |
| 2102 | * @brief Alignment type. |
| 2103 | * |
| 2104 | * The value of _Align is a default-alignment which shall be the |
| 2105 | * most stringent alignment requirement for any C++ object type |
| 2106 | * whose size is no greater than _Len (3.9). The member typedef |
| 2107 | * type shall be a POD type suitable for use as uninitialized |
| 2108 | * storage for any object whose size is at most _Len and whose |
| 2109 | * alignment is a divisor of _Align. |
| 2110 | */ |
| 2111 | template<std::size_t _Len, std::size_t _Align = |
| 2112 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> |
| 2113 | struct aligned_storage |
| 2114 | { |
| 2115 | union type |
| 2116 | { |
| 2117 | unsigned char __data[_Len]; |
| 2118 | struct __attribute__((__aligned__((_Align)))) { } __align; |
| 2119 | }; |
| 2120 | }; |
| 2121 | |
| 2122 | template <typename... _Types> |
| 2123 | struct __strictest_alignment |
| 2124 | { |
| 2125 | static const size_t _S_alignment = 0; |
| 2126 | static const size_t _S_size = 0; |
| 2127 | }; |
| 2128 | |
| 2129 | template <typename _Tp, typename... _Types> |
| 2130 | struct __strictest_alignment<_Tp, _Types...> |
| 2131 | { |
| 2132 | static const size_t _S_alignment = |
| 2133 | alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment |
| 2134 | ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; |
| 2135 | static const size_t _S_size = |
| 2136 | sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size |
| 2137 | ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; |
| 2138 | }; |
| 2139 | |
| 2140 | /** |
| 2141 | * @brief Provide aligned storage for types. |
| 2142 | * |
| 2143 | * [meta.trans.other] |
| 2144 | * |
| 2145 | * Provides aligned storage for any of the provided types of at |
| 2146 | * least size _Len. |
| 2147 | * |
| 2148 | * @see aligned_storage |
| 2149 | */ |
| 2150 | template <size_t _Len, typename... _Types> |
| 2151 | struct aligned_union |
| 2152 | { |
| 2153 | private: |
| 2154 | static_assert(sizeof...(_Types) != 0, "At least one type is required" ); |
| 2155 | |
| 2156 | using __strictest = __strictest_alignment<_Types...>; |
| 2157 | static const size_t _S_len = _Len > __strictest::_S_size |
| 2158 | ? _Len : __strictest::_S_size; |
| 2159 | public: |
| 2160 | /// The value of the strictest alignment of _Types. |
| 2161 | static const size_t alignment_value = __strictest::_S_alignment; |
| 2162 | /// The storage. |
| 2163 | typedef typename aligned_storage<_S_len, alignment_value>::type type; |
| 2164 | }; |
| 2165 | |
| 2166 | template <size_t _Len, typename... _Types> |
| 2167 | const size_t aligned_union<_Len, _Types...>::alignment_value; |
| 2168 | |
| 2169 | /// @cond undocumented |
| 2170 | |
| 2171 | // Decay trait for arrays and functions, used for perfect forwarding |
| 2172 | // in make_pair, make_tuple, etc. |
| 2173 | template<typename _Up, |
| 2174 | bool _IsArray = is_array<_Up>::value, |
| 2175 | bool _IsFunction = is_function<_Up>::value> |
| 2176 | struct __decay_selector; |
| 2177 | |
| 2178 | // NB: DR 705. |
| 2179 | template<typename _Up> |
| 2180 | struct __decay_selector<_Up, false, false> |
| 2181 | { typedef __remove_cv_t<_Up> __type; }; |
| 2182 | |
| 2183 | template<typename _Up> |
| 2184 | struct __decay_selector<_Up, true, false> |
| 2185 | { typedef typename remove_extent<_Up>::type* __type; }; |
| 2186 | |
| 2187 | template<typename _Up> |
| 2188 | struct __decay_selector<_Up, false, true> |
| 2189 | { typedef typename add_pointer<_Up>::type __type; }; |
| 2190 | /// @endcond |
| 2191 | |
| 2192 | /// decay |
| 2193 | template<typename _Tp> |
| 2194 | class decay |
| 2195 | { |
| 2196 | typedef typename remove_reference<_Tp>::type __remove_type; |
| 2197 | |
| 2198 | public: |
| 2199 | typedef typename __decay_selector<__remove_type>::__type type; |
| 2200 | }; |
| 2201 | |
| 2202 | /// @cond undocumented |
| 2203 | |
| 2204 | // Helper which adds a reference to a type when given a reference_wrapper |
| 2205 | template<typename _Tp> |
| 2206 | struct __strip_reference_wrapper |
| 2207 | { |
| 2208 | typedef _Tp __type; |
| 2209 | }; |
| 2210 | |
| 2211 | template<typename _Tp> |
| 2212 | struct __strip_reference_wrapper<reference_wrapper<_Tp> > |
| 2213 | { |
| 2214 | typedef _Tp& __type; |
| 2215 | }; |
| 2216 | |
| 2217 | // __decay_t (std::decay_t for C++11). |
| 2218 | template<typename _Tp> |
| 2219 | using __decay_t = typename decay<_Tp>::type; |
| 2220 | |
| 2221 | template<typename _Tp> |
| 2222 | using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>; |
| 2223 | /// @endcond |
| 2224 | |
| 2225 | // Primary template. |
| 2226 | /// Define a member typedef `type` only if a boolean constant is true. |
| 2227 | template<bool, typename _Tp = void> |
| 2228 | struct enable_if |
| 2229 | { }; |
| 2230 | |
| 2231 | // Partial specialization for true. |
| 2232 | template<typename _Tp> |
| 2233 | struct enable_if<true, _Tp> |
| 2234 | { typedef _Tp type; }; |
| 2235 | |
| 2236 | /// @cond undocumented |
| 2237 | |
| 2238 | // __enable_if_t (std::enable_if_t for C++11) |
| 2239 | template<bool _Cond, typename _Tp = void> |
| 2240 | using __enable_if_t = typename enable_if<_Cond, _Tp>::type; |
| 2241 | |
| 2242 | // Helper for SFINAE constraints |
| 2243 | template<typename... _Cond> |
| 2244 | using _Require = __enable_if_t<__and_<_Cond...>::value>; |
| 2245 | |
| 2246 | // __remove_cvref_t (std::remove_cvref_t for C++11). |
| 2247 | template<typename _Tp> |
| 2248 | using __remove_cvref_t |
| 2249 | = typename remove_cv<typename remove_reference<_Tp>::type>::type; |
| 2250 | /// @endcond |
| 2251 | |
| 2252 | // Primary template. |
| 2253 | /// Define a member typedef @c type to one of two argument types. |
| 2254 | template<bool _Cond, typename _Iftrue, typename _Iffalse> |
| 2255 | struct conditional |
| 2256 | { typedef _Iftrue type; }; |
| 2257 | |
| 2258 | // Partial specialization for false. |
| 2259 | template<typename _Iftrue, typename _Iffalse> |
| 2260 | struct conditional<false, _Iftrue, _Iffalse> |
| 2261 | { typedef _Iffalse type; }; |
| 2262 | |
| 2263 | /// common_type |
| 2264 | template<typename... _Tp> |
| 2265 | struct common_type; |
| 2266 | |
| 2267 | // Sfinae-friendly common_type implementation: |
| 2268 | |
| 2269 | /// @cond undocumented |
| 2270 | struct __do_common_type_impl |
| 2271 | { |
| 2272 | template<typename _Tp, typename _Up> |
| 2273 | using __cond_t |
| 2274 | = decltype(true ? std::declval<_Tp>() : std::declval<_Up>()); |
| 2275 | |
| 2276 | // if decay_t<decltype(false ? declval<D1>() : declval<D2>())> |
| 2277 | // denotes a valid type, let C denote that type. |
| 2278 | template<typename _Tp, typename _Up> |
| 2279 | static __success_type<__decay_t<__cond_t<_Tp, _Up>>> |
| 2280 | _S_test(int); |
| 2281 | |
| 2282 | #if __cplusplus > 201703L |
| 2283 | // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type, |
| 2284 | // let C denote the type decay_t<COND-RES(CREF(D1), CREF(D2))>. |
| 2285 | template<typename _Tp, typename _Up> |
| 2286 | static __success_type<__remove_cvref_t<__cond_t<const _Tp&, const _Up&>>> |
| 2287 | _S_test_2(int); |
| 2288 | #endif |
| 2289 | |
| 2290 | template<typename, typename> |
| 2291 | static __failure_type |
| 2292 | _S_test_2(...); |
| 2293 | |
| 2294 | template<typename _Tp, typename _Up> |
| 2295 | static decltype(_S_test_2<_Tp, _Up>(0)) |
| 2296 | _S_test(...); |
| 2297 | }; |
| 2298 | |
| 2299 | // If sizeof...(T) is zero, there shall be no member type. |
| 2300 | template<> |
| 2301 | struct common_type<> |
| 2302 | { }; |
| 2303 | |
| 2304 | // If sizeof...(T) is one, the same type, if any, as common_type_t<T0, T0>. |
| 2305 | template<typename _Tp0> |
| 2306 | struct common_type<_Tp0> |
| 2307 | : public common_type<_Tp0, _Tp0> |
| 2308 | { }; |
| 2309 | |
| 2310 | // If sizeof...(T) is two, ... |
| 2311 | template<typename _Tp1, typename _Tp2, |
| 2312 | typename _Dp1 = __decay_t<_Tp1>, typename _Dp2 = __decay_t<_Tp2>> |
| 2313 | struct __common_type_impl |
| 2314 | { |
| 2315 | // If is_same_v<T1, D1> is false or is_same_v<T2, D2> is false, |
| 2316 | // let C denote the same type, if any, as common_type_t<D1, D2>. |
| 2317 | using type = common_type<_Dp1, _Dp2>; |
| 2318 | }; |
| 2319 | |
| 2320 | template<typename _Tp1, typename _Tp2> |
| 2321 | struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2> |
| 2322 | : private __do_common_type_impl |
| 2323 | { |
| 2324 | // Otherwise, if decay_t<decltype(false ? declval<D1>() : declval<D2>())> |
| 2325 | // denotes a valid type, let C denote that type. |
| 2326 | using type = decltype(_S_test<_Tp1, _Tp2>(0)); |
| 2327 | }; |
| 2328 | |
| 2329 | // If sizeof...(T) is two, ... |
| 2330 | template<typename _Tp1, typename _Tp2> |
| 2331 | struct common_type<_Tp1, _Tp2> |
| 2332 | : public __common_type_impl<_Tp1, _Tp2>::type |
| 2333 | { }; |
| 2334 | |
| 2335 | template<typename...> |
| 2336 | struct __common_type_pack |
| 2337 | { }; |
| 2338 | |
| 2339 | template<typename, typename, typename = void> |
| 2340 | struct __common_type_fold; |
| 2341 | |
| 2342 | // If sizeof...(T) is greater than two, ... |
| 2343 | template<typename _Tp1, typename _Tp2, typename... _Rp> |
| 2344 | struct common_type<_Tp1, _Tp2, _Rp...> |
| 2345 | : public __common_type_fold<common_type<_Tp1, _Tp2>, |
| 2346 | __common_type_pack<_Rp...>> |
| 2347 | { }; |
| 2348 | |
| 2349 | // Let C denote the same type, if any, as common_type_t<T1, T2>. |
| 2350 | // If there is such a type C, type shall denote the same type, if any, |
| 2351 | // as common_type_t<C, R...>. |
| 2352 | template<typename _CTp, typename... _Rp> |
| 2353 | struct __common_type_fold<_CTp, __common_type_pack<_Rp...>, |
| 2354 | __void_t<typename _CTp::type>> |
| 2355 | : public common_type<typename _CTp::type, _Rp...> |
| 2356 | { }; |
| 2357 | |
| 2358 | // Otherwise, there shall be no member type. |
| 2359 | template<typename _CTp, typename _Rp> |
| 2360 | struct __common_type_fold<_CTp, _Rp, void> |
| 2361 | { }; |
| 2362 | |
| 2363 | template<typename _Tp, bool = is_enum<_Tp>::value> |
| 2364 | struct __underlying_type_impl |
| 2365 | { |
| 2366 | using type = __underlying_type(_Tp); |
| 2367 | }; |
| 2368 | |
| 2369 | template<typename _Tp> |
| 2370 | struct __underlying_type_impl<_Tp, false> |
| 2371 | { }; |
| 2372 | /// @endcond |
| 2373 | |
| 2374 | /// The underlying type of an enum. |
| 2375 | template<typename _Tp> |
| 2376 | struct underlying_type |
| 2377 | : public __underlying_type_impl<_Tp> |
| 2378 | { }; |
| 2379 | |
| 2380 | /// @cond undocumented |
| 2381 | template<typename _Tp> |
| 2382 | struct __declval_protector |
| 2383 | { |
| 2384 | static const bool __stop = false; |
| 2385 | }; |
| 2386 | /// @endcond |
| 2387 | |
| 2388 | /** Utility to simplify expressions used in unevaluated operands |
| 2389 | * @since C++11 |
| 2390 | * @ingroup utilities |
| 2391 | */ |
| 2392 | template<typename _Tp> |
| 2393 | auto declval() noexcept -> decltype(__declval<_Tp>(0)) |
| 2394 | { |
| 2395 | static_assert(__declval_protector<_Tp>::__stop, |
| 2396 | "declval() must not be used!" ); |
| 2397 | return __declval<_Tp>(0); |
| 2398 | } |
| 2399 | |
| 2400 | /// result_of |
| 2401 | template<typename _Signature> |
| 2402 | struct result_of; |
| 2403 | |
| 2404 | // Sfinae-friendly result_of implementation: |
| 2405 | |
| 2406 | #define __cpp_lib_result_of_sfinae 201210L |
| 2407 | |
| 2408 | /// @cond undocumented |
| 2409 | struct __invoke_memfun_ref { }; |
| 2410 | struct __invoke_memfun_deref { }; |
| 2411 | struct __invoke_memobj_ref { }; |
| 2412 | struct __invoke_memobj_deref { }; |
| 2413 | struct __invoke_other { }; |
| 2414 | |
| 2415 | // Associate a tag type with a specialization of __success_type. |
| 2416 | template<typename _Tp, typename _Tag> |
| 2417 | struct __result_of_success : __success_type<_Tp> |
| 2418 | { using __invoke_type = _Tag; }; |
| 2419 | |
| 2420 | // [func.require] paragraph 1 bullet 1: |
| 2421 | struct __result_of_memfun_ref_impl |
| 2422 | { |
| 2423 | template<typename _Fp, typename _Tp1, typename... _Args> |
| 2424 | static __result_of_success<decltype( |
| 2425 | (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) |
| 2426 | ), __invoke_memfun_ref> _S_test(int); |
| 2427 | |
| 2428 | template<typename...> |
| 2429 | static __failure_type _S_test(...); |
| 2430 | }; |
| 2431 | |
| 2432 | template<typename _MemPtr, typename _Arg, typename... _Args> |
| 2433 | struct __result_of_memfun_ref |
| 2434 | : private __result_of_memfun_ref_impl |
| 2435 | { |
| 2436 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; |
| 2437 | }; |
| 2438 | |
| 2439 | // [func.require] paragraph 1 bullet 2: |
| 2440 | struct __result_of_memfun_deref_impl |
| 2441 | { |
| 2442 | template<typename _Fp, typename _Tp1, typename... _Args> |
| 2443 | static __result_of_success<decltype( |
| 2444 | ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) |
| 2445 | ), __invoke_memfun_deref> _S_test(int); |
| 2446 | |
| 2447 | template<typename...> |
| 2448 | static __failure_type _S_test(...); |
| 2449 | }; |
| 2450 | |
| 2451 | template<typename _MemPtr, typename _Arg, typename... _Args> |
| 2452 | struct __result_of_memfun_deref |
| 2453 | : private __result_of_memfun_deref_impl |
| 2454 | { |
| 2455 | typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; |
| 2456 | }; |
| 2457 | |
| 2458 | // [func.require] paragraph 1 bullet 3: |
| 2459 | struct __result_of_memobj_ref_impl |
| 2460 | { |
| 2461 | template<typename _Fp, typename _Tp1> |
| 2462 | static __result_of_success<decltype( |
| 2463 | std::declval<_Tp1>().*std::declval<_Fp>() |
| 2464 | ), __invoke_memobj_ref> _S_test(int); |
| 2465 | |
| 2466 | template<typename, typename> |
| 2467 | static __failure_type _S_test(...); |
| 2468 | }; |
| 2469 | |
| 2470 | template<typename _MemPtr, typename _Arg> |
| 2471 | struct __result_of_memobj_ref |
| 2472 | : private __result_of_memobj_ref_impl |
| 2473 | { |
| 2474 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; |
| 2475 | }; |
| 2476 | |
| 2477 | // [func.require] paragraph 1 bullet 4: |
| 2478 | struct __result_of_memobj_deref_impl |
| 2479 | { |
| 2480 | template<typename _Fp, typename _Tp1> |
| 2481 | static __result_of_success<decltype( |
| 2482 | (*std::declval<_Tp1>()).*std::declval<_Fp>() |
| 2483 | ), __invoke_memobj_deref> _S_test(int); |
| 2484 | |
| 2485 | template<typename, typename> |
| 2486 | static __failure_type _S_test(...); |
| 2487 | }; |
| 2488 | |
| 2489 | template<typename _MemPtr, typename _Arg> |
| 2490 | struct __result_of_memobj_deref |
| 2491 | : private __result_of_memobj_deref_impl |
| 2492 | { |
| 2493 | typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; |
| 2494 | }; |
| 2495 | |
| 2496 | template<typename _MemPtr, typename _Arg> |
| 2497 | struct __result_of_memobj; |
| 2498 | |
| 2499 | template<typename _Res, typename _Class, typename _Arg> |
| 2500 | struct __result_of_memobj<_Res _Class::*, _Arg> |
| 2501 | { |
| 2502 | typedef __remove_cvref_t<_Arg> _Argval; |
| 2503 | typedef _Res _Class::* _MemPtr; |
| 2504 | typedef typename __conditional_t<__or_<is_same<_Argval, _Class>, |
| 2505 | is_base_of<_Class, _Argval>>::value, |
| 2506 | __result_of_memobj_ref<_MemPtr, _Arg>, |
| 2507 | __result_of_memobj_deref<_MemPtr, _Arg> |
| 2508 | >::type type; |
| 2509 | }; |
| 2510 | |
| 2511 | template<typename _MemPtr, typename _Arg, typename... _Args> |
| 2512 | struct __result_of_memfun; |
| 2513 | |
| 2514 | template<typename _Res, typename _Class, typename _Arg, typename... _Args> |
| 2515 | struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> |
| 2516 | { |
| 2517 | typedef typename remove_reference<_Arg>::type _Argval; |
| 2518 | typedef _Res _Class::* _MemPtr; |
| 2519 | typedef typename __conditional_t<is_base_of<_Class, _Argval>::value, |
| 2520 | __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, |
| 2521 | __result_of_memfun_deref<_MemPtr, _Arg, _Args...> |
| 2522 | >::type type; |
| 2523 | }; |
| 2524 | |
| 2525 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
| 2526 | // 2219. INVOKE-ing a pointer to member with a reference_wrapper |
| 2527 | // as the object expression |
| 2528 | |
| 2529 | // Used by result_of, invoke etc. to unwrap a reference_wrapper. |
| 2530 | template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>> |
| 2531 | struct __inv_unwrap |
| 2532 | { |
| 2533 | using type = _Tp; |
| 2534 | }; |
| 2535 | |
| 2536 | template<typename _Tp, typename _Up> |
| 2537 | struct __inv_unwrap<_Tp, reference_wrapper<_Up>> |
| 2538 | { |
| 2539 | using type = _Up&; |
| 2540 | }; |
| 2541 | |
| 2542 | template<bool, bool, typename _Functor, typename... _ArgTypes> |
| 2543 | struct __result_of_impl |
| 2544 | { |
| 2545 | typedef __failure_type type; |
| 2546 | }; |
| 2547 | |
| 2548 | template<typename _MemPtr, typename _Arg> |
| 2549 | struct __result_of_impl<true, false, _MemPtr, _Arg> |
| 2550 | : public __result_of_memobj<__decay_t<_MemPtr>, |
| 2551 | typename __inv_unwrap<_Arg>::type> |
| 2552 | { }; |
| 2553 | |
| 2554 | template<typename _MemPtr, typename _Arg, typename... _Args> |
| 2555 | struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> |
| 2556 | : public __result_of_memfun<__decay_t<_MemPtr>, |
| 2557 | typename __inv_unwrap<_Arg>::type, _Args...> |
| 2558 | { }; |
| 2559 | |
| 2560 | // [func.require] paragraph 1 bullet 5: |
| 2561 | struct __result_of_other_impl |
| 2562 | { |
| 2563 | template<typename _Fn, typename... _Args> |
| 2564 | static __result_of_success<decltype( |
| 2565 | std::declval<_Fn>()(std::declval<_Args>()...) |
| 2566 | ), __invoke_other> _S_test(int); |
| 2567 | |
| 2568 | template<typename...> |
| 2569 | static __failure_type _S_test(...); |
| 2570 | }; |
| 2571 | |
| 2572 | template<typename _Functor, typename... _ArgTypes> |
| 2573 | struct __result_of_impl<false, false, _Functor, _ArgTypes...> |
| 2574 | : private __result_of_other_impl |
| 2575 | { |
| 2576 | typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; |
| 2577 | }; |
| 2578 | |
| 2579 | // __invoke_result (std::invoke_result for C++11) |
| 2580 | template<typename _Functor, typename... _ArgTypes> |
| 2581 | struct __invoke_result |
| 2582 | : public __result_of_impl< |
| 2583 | is_member_object_pointer< |
| 2584 | typename remove_reference<_Functor>::type |
| 2585 | >::value, |
| 2586 | is_member_function_pointer< |
| 2587 | typename remove_reference<_Functor>::type |
| 2588 | >::value, |
| 2589 | _Functor, _ArgTypes... |
| 2590 | >::type |
| 2591 | { }; |
| 2592 | /// @endcond |
| 2593 | |
| 2594 | template<typename _Functor, typename... _ArgTypes> |
| 2595 | struct result_of<_Functor(_ArgTypes...)> |
| 2596 | : public __invoke_result<_Functor, _ArgTypes...> |
| 2597 | { } _GLIBCXX17_DEPRECATED_SUGGEST("std::invoke_result" ); |
| 2598 | |
| 2599 | #if __cplusplus >= 201402L |
| 2600 | /// Alias template for aligned_storage |
| 2601 | template<size_t _Len, size_t _Align = |
| 2602 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> |
| 2603 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; |
| 2604 | |
| 2605 | template <size_t _Len, typename... _Types> |
| 2606 | using aligned_union_t = typename aligned_union<_Len, _Types...>::type; |
| 2607 | |
| 2608 | /// Alias template for decay |
| 2609 | template<typename _Tp> |
| 2610 | using decay_t = typename decay<_Tp>::type; |
| 2611 | |
| 2612 | /// Alias template for enable_if |
| 2613 | template<bool _Cond, typename _Tp = void> |
| 2614 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; |
| 2615 | |
| 2616 | /// Alias template for conditional |
| 2617 | template<bool _Cond, typename _Iftrue, typename _Iffalse> |
| 2618 | using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; |
| 2619 | |
| 2620 | /// Alias template for common_type |
| 2621 | template<typename... _Tp> |
| 2622 | using common_type_t = typename common_type<_Tp...>::type; |
| 2623 | |
| 2624 | /// Alias template for underlying_type |
| 2625 | template<typename _Tp> |
| 2626 | using underlying_type_t = typename underlying_type<_Tp>::type; |
| 2627 | |
| 2628 | /// Alias template for result_of |
| 2629 | template<typename _Tp> |
| 2630 | using result_of_t = typename result_of<_Tp>::type; |
| 2631 | #endif // C++14 |
| 2632 | |
| 2633 | #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 |
| 2634 | #define __cpp_lib_void_t 201411L |
| 2635 | /// A metafunction that always yields void, used for detecting valid types. |
| 2636 | template<typename...> using void_t = void; |
| 2637 | #endif |
| 2638 | |
| 2639 | /// @cond undocumented |
| 2640 | |
| 2641 | /// Implementation of the detection idiom (negative case). |
| 2642 | template<typename _Default, typename _AlwaysVoid, |
| 2643 | template<typename...> class _Op, typename... _Args> |
| 2644 | struct __detector |
| 2645 | { |
| 2646 | using value_t = false_type; |
| 2647 | using type = _Default; |
| 2648 | }; |
| 2649 | |
| 2650 | /// Implementation of the detection idiom (positive case). |
| 2651 | template<typename _Default, template<typename...> class _Op, |
| 2652 | typename... _Args> |
| 2653 | struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> |
| 2654 | { |
| 2655 | using value_t = true_type; |
| 2656 | using type = _Op<_Args...>; |
| 2657 | }; |
| 2658 | |
| 2659 | // Detect whether _Op<_Args...> is a valid type, use _Default if not. |
| 2660 | template<typename _Default, template<typename...> class _Op, |
| 2661 | typename... _Args> |
| 2662 | using __detected_or = __detector<_Default, void, _Op, _Args...>; |
| 2663 | |
| 2664 | // _Op<_Args...> if that is a valid type, otherwise _Default. |
| 2665 | template<typename _Default, template<typename...> class _Op, |
| 2666 | typename... _Args> |
| 2667 | using __detected_or_t |
| 2668 | = typename __detected_or<_Default, _Op, _Args...>::type; |
| 2669 | |
| 2670 | /** |
| 2671 | * Use SFINAE to determine if the type _Tp has a publicly-accessible |
| 2672 | * member type _NTYPE. |
| 2673 | */ |
| 2674 | #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ |
| 2675 | template<typename _Tp, typename = __void_t<>> \ |
| 2676 | struct __has_##_NTYPE \ |
| 2677 | : false_type \ |
| 2678 | { }; \ |
| 2679 | template<typename _Tp> \ |
| 2680 | struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ |
| 2681 | : true_type \ |
| 2682 | { }; |
| 2683 | |
| 2684 | template <typename _Tp> |
| 2685 | struct __is_swappable; |
| 2686 | |
| 2687 | template <typename _Tp> |
| 2688 | struct __is_nothrow_swappable; |
| 2689 | |
| 2690 | template<typename> |
| 2691 | struct __is_tuple_like_impl : false_type |
| 2692 | { }; |
| 2693 | |
| 2694 | // Internal type trait that allows us to sfinae-protect tuple_cat. |
| 2695 | template<typename _Tp> |
| 2696 | struct __is_tuple_like |
| 2697 | : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type |
| 2698 | { }; |
| 2699 | /// @endcond |
| 2700 | |
| 2701 | template<typename _Tp> |
| 2702 | _GLIBCXX20_CONSTEXPR |
| 2703 | inline |
| 2704 | _Require<__not_<__is_tuple_like<_Tp>>, |
| 2705 | is_move_constructible<_Tp>, |
| 2706 | is_move_assignable<_Tp>> |
| 2707 | swap(_Tp&, _Tp&) |
| 2708 | noexcept(__and_<is_nothrow_move_constructible<_Tp>, |
| 2709 | is_nothrow_move_assignable<_Tp>>::value); |
| 2710 | |
| 2711 | template<typename _Tp, size_t _Nm> |
| 2712 | _GLIBCXX20_CONSTEXPR |
| 2713 | inline |
| 2714 | __enable_if_t<__is_swappable<_Tp>::value> |
| 2715 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) |
| 2716 | noexcept(__is_nothrow_swappable<_Tp>::value); |
| 2717 | |
| 2718 | /// @cond undocumented |
| 2719 | namespace __swappable_details { |
| 2720 | using std::swap; |
| 2721 | |
| 2722 | struct __do_is_swappable_impl |
| 2723 | { |
| 2724 | template<typename _Tp, typename |
| 2725 | = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> |
| 2726 | static true_type __test(int); |
| 2727 | |
| 2728 | template<typename> |
| 2729 | static false_type __test(...); |
| 2730 | }; |
| 2731 | |
| 2732 | struct __do_is_nothrow_swappable_impl |
| 2733 | { |
| 2734 | template<typename _Tp> |
| 2735 | static __bool_constant< |
| 2736 | noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) |
| 2737 | > __test(int); |
| 2738 | |
| 2739 | template<typename> |
| 2740 | static false_type __test(...); |
| 2741 | }; |
| 2742 | |
| 2743 | } // namespace __swappable_details |
| 2744 | |
| 2745 | template<typename _Tp> |
| 2746 | struct __is_swappable_impl |
| 2747 | : public __swappable_details::__do_is_swappable_impl |
| 2748 | { |
| 2749 | typedef decltype(__test<_Tp>(0)) type; |
| 2750 | }; |
| 2751 | |
| 2752 | template<typename _Tp> |
| 2753 | struct __is_nothrow_swappable_impl |
| 2754 | : public __swappable_details::__do_is_nothrow_swappable_impl |
| 2755 | { |
| 2756 | typedef decltype(__test<_Tp>(0)) type; |
| 2757 | }; |
| 2758 | |
| 2759 | template<typename _Tp> |
| 2760 | struct __is_swappable |
| 2761 | : public __is_swappable_impl<_Tp>::type |
| 2762 | { }; |
| 2763 | |
| 2764 | template<typename _Tp> |
| 2765 | struct __is_nothrow_swappable |
| 2766 | : public __is_nothrow_swappable_impl<_Tp>::type |
| 2767 | { }; |
| 2768 | /// @endcond |
| 2769 | |
| 2770 | #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 |
| 2771 | #define __cpp_lib_is_swappable 201603L |
| 2772 | /// Metafunctions used for detecting swappable types: p0185r1 |
| 2773 | |
| 2774 | /// is_swappable |
| 2775 | template<typename _Tp> |
| 2776 | struct is_swappable |
| 2777 | : public __is_swappable_impl<_Tp>::type |
| 2778 | { |
| 2779 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 2780 | "template argument must be a complete class or an unbounded array" ); |
| 2781 | }; |
| 2782 | |
| 2783 | /// is_nothrow_swappable |
| 2784 | template<typename _Tp> |
| 2785 | struct is_nothrow_swappable |
| 2786 | : public __is_nothrow_swappable_impl<_Tp>::type |
| 2787 | { |
| 2788 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 2789 | "template argument must be a complete class or an unbounded array" ); |
| 2790 | }; |
| 2791 | |
| 2792 | #if __cplusplus >= 201402L |
| 2793 | /// is_swappable_v |
| 2794 | template<typename _Tp> |
| 2795 | _GLIBCXX17_INLINE constexpr bool is_swappable_v = |
| 2796 | is_swappable<_Tp>::value; |
| 2797 | |
| 2798 | /// is_nothrow_swappable_v |
| 2799 | template<typename _Tp> |
| 2800 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = |
| 2801 | is_nothrow_swappable<_Tp>::value; |
| 2802 | #endif // __cplusplus >= 201402L |
| 2803 | |
| 2804 | /// @cond undocumented |
| 2805 | namespace __swappable_with_details { |
| 2806 | using std::swap; |
| 2807 | |
| 2808 | struct __do_is_swappable_with_impl |
| 2809 | { |
| 2810 | template<typename _Tp, typename _Up, typename |
| 2811 | = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), |
| 2812 | typename |
| 2813 | = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> |
| 2814 | static true_type __test(int); |
| 2815 | |
| 2816 | template<typename, typename> |
| 2817 | static false_type __test(...); |
| 2818 | }; |
| 2819 | |
| 2820 | struct __do_is_nothrow_swappable_with_impl |
| 2821 | { |
| 2822 | template<typename _Tp, typename _Up> |
| 2823 | static __bool_constant< |
| 2824 | noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) |
| 2825 | && |
| 2826 | noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) |
| 2827 | > __test(int); |
| 2828 | |
| 2829 | template<typename, typename> |
| 2830 | static false_type __test(...); |
| 2831 | }; |
| 2832 | |
| 2833 | } // namespace __swappable_with_details |
| 2834 | |
| 2835 | template<typename _Tp, typename _Up> |
| 2836 | struct __is_swappable_with_impl |
| 2837 | : public __swappable_with_details::__do_is_swappable_with_impl |
| 2838 | { |
| 2839 | typedef decltype(__test<_Tp, _Up>(0)) type; |
| 2840 | }; |
| 2841 | |
| 2842 | // Optimization for the homogenous lvalue case, not required: |
| 2843 | template<typename _Tp> |
| 2844 | struct __is_swappable_with_impl<_Tp&, _Tp&> |
| 2845 | : public __swappable_details::__do_is_swappable_impl |
| 2846 | { |
| 2847 | typedef decltype(__test<_Tp&>(0)) type; |
| 2848 | }; |
| 2849 | |
| 2850 | template<typename _Tp, typename _Up> |
| 2851 | struct __is_nothrow_swappable_with_impl |
| 2852 | : public __swappable_with_details::__do_is_nothrow_swappable_with_impl |
| 2853 | { |
| 2854 | typedef decltype(__test<_Tp, _Up>(0)) type; |
| 2855 | }; |
| 2856 | |
| 2857 | // Optimization for the homogenous lvalue case, not required: |
| 2858 | template<typename _Tp> |
| 2859 | struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> |
| 2860 | : public __swappable_details::__do_is_nothrow_swappable_impl |
| 2861 | { |
| 2862 | typedef decltype(__test<_Tp&>(0)) type; |
| 2863 | }; |
| 2864 | /// @endcond |
| 2865 | |
| 2866 | /// is_swappable_with |
| 2867 | template<typename _Tp, typename _Up> |
| 2868 | struct is_swappable_with |
| 2869 | : public __is_swappable_with_impl<_Tp, _Up>::type |
| 2870 | { |
| 2871 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 2872 | "first template argument must be a complete class or an unbounded array" ); |
| 2873 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), |
| 2874 | "second template argument must be a complete class or an unbounded array" ); |
| 2875 | }; |
| 2876 | |
| 2877 | /// is_nothrow_swappable_with |
| 2878 | template<typename _Tp, typename _Up> |
| 2879 | struct is_nothrow_swappable_with |
| 2880 | : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type |
| 2881 | { |
| 2882 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 2883 | "first template argument must be a complete class or an unbounded array" ); |
| 2884 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), |
| 2885 | "second template argument must be a complete class or an unbounded array" ); |
| 2886 | }; |
| 2887 | |
| 2888 | #if __cplusplus >= 201402L |
| 2889 | /// is_swappable_with_v |
| 2890 | template<typename _Tp, typename _Up> |
| 2891 | _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = |
| 2892 | is_swappable_with<_Tp, _Up>::value; |
| 2893 | |
| 2894 | /// is_nothrow_swappable_with_v |
| 2895 | template<typename _Tp, typename _Up> |
| 2896 | _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = |
| 2897 | is_nothrow_swappable_with<_Tp, _Up>::value; |
| 2898 | #endif // __cplusplus >= 201402L |
| 2899 | |
| 2900 | #endif// c++1z or gnu++11 |
| 2901 | |
| 2902 | /// @cond undocumented |
| 2903 | |
| 2904 | // __is_invocable (std::is_invocable for C++11) |
| 2905 | |
| 2906 | // The primary template is used for invalid INVOKE expressions. |
| 2907 | template<typename _Result, typename _Ret, |
| 2908 | bool = is_void<_Ret>::value, typename = void> |
| 2909 | struct __is_invocable_impl : false_type { }; |
| 2910 | |
| 2911 | // Used for valid INVOKE and INVOKE<void> expressions. |
| 2912 | template<typename _Result, typename _Ret> |
| 2913 | struct __is_invocable_impl<_Result, _Ret, |
| 2914 | /* is_void<_Ret> = */ true, |
| 2915 | __void_t<typename _Result::type>> |
| 2916 | : true_type |
| 2917 | { }; |
| 2918 | |
| 2919 | #pragma GCC diagnostic push |
| 2920 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
| 2921 | // Used for INVOKE<R> expressions to check the implicit conversion to R. |
| 2922 | template<typename _Result, typename _Ret> |
| 2923 | struct __is_invocable_impl<_Result, _Ret, |
| 2924 | /* is_void<_Ret> = */ false, |
| 2925 | __void_t<typename _Result::type>> |
| 2926 | { |
| 2927 | private: |
| 2928 | // The type of the INVOKE expression. |
| 2929 | // Unlike declval, this doesn't add_rvalue_reference. |
| 2930 | static typename _Result::type _S_get(); |
| 2931 | |
| 2932 | template<typename _Tp> |
| 2933 | static void _S_conv(_Tp); |
| 2934 | |
| 2935 | // This overload is viable if INVOKE(f, args...) can convert to _Tp. |
| 2936 | template<typename _Tp, typename = decltype(_S_conv<_Tp>(_S_get()))> |
| 2937 | static true_type |
| 2938 | _S_test(int); |
| 2939 | |
| 2940 | template<typename _Tp> |
| 2941 | static false_type |
| 2942 | _S_test(...); |
| 2943 | |
| 2944 | public: |
| 2945 | using type = decltype(_S_test<_Ret>(1)); |
| 2946 | }; |
| 2947 | #pragma GCC diagnostic pop |
| 2948 | |
| 2949 | template<typename _Fn, typename... _ArgTypes> |
| 2950 | struct __is_invocable |
| 2951 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type |
| 2952 | { }; |
| 2953 | |
| 2954 | template<typename _Fn, typename _Tp, typename... _Args> |
| 2955 | constexpr bool __call_is_nt(__invoke_memfun_ref) |
| 2956 | { |
| 2957 | using _Up = typename __inv_unwrap<_Tp>::type; |
| 2958 | return noexcept((std::declval<_Up>().*std::declval<_Fn>())( |
| 2959 | std::declval<_Args>()...)); |
| 2960 | } |
| 2961 | |
| 2962 | template<typename _Fn, typename _Tp, typename... _Args> |
| 2963 | constexpr bool __call_is_nt(__invoke_memfun_deref) |
| 2964 | { |
| 2965 | return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( |
| 2966 | std::declval<_Args>()...)); |
| 2967 | } |
| 2968 | |
| 2969 | template<typename _Fn, typename _Tp> |
| 2970 | constexpr bool __call_is_nt(__invoke_memobj_ref) |
| 2971 | { |
| 2972 | using _Up = typename __inv_unwrap<_Tp>::type; |
| 2973 | return noexcept(std::declval<_Up>().*std::declval<_Fn>()); |
| 2974 | } |
| 2975 | |
| 2976 | template<typename _Fn, typename _Tp> |
| 2977 | constexpr bool __call_is_nt(__invoke_memobj_deref) |
| 2978 | { |
| 2979 | return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); |
| 2980 | } |
| 2981 | |
| 2982 | template<typename _Fn, typename... _Args> |
| 2983 | constexpr bool __call_is_nt(__invoke_other) |
| 2984 | { |
| 2985 | return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); |
| 2986 | } |
| 2987 | |
| 2988 | template<typename _Result, typename _Fn, typename... _Args> |
| 2989 | struct __call_is_nothrow |
| 2990 | : __bool_constant< |
| 2991 | std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) |
| 2992 | > |
| 2993 | { }; |
| 2994 | |
| 2995 | template<typename _Fn, typename... _Args> |
| 2996 | using __call_is_nothrow_ |
| 2997 | = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; |
| 2998 | |
| 2999 | // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) |
| 3000 | template<typename _Fn, typename... _Args> |
| 3001 | struct __is_nothrow_invocable |
| 3002 | : __and_<__is_invocable<_Fn, _Args...>, |
| 3003 | __call_is_nothrow_<_Fn, _Args...>>::type |
| 3004 | { }; |
| 3005 | |
| 3006 | #pragma GCC diagnostic push |
| 3007 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
| 3008 | struct __nonesuchbase {}; |
| 3009 | struct __nonesuch : private __nonesuchbase { |
| 3010 | ~__nonesuch() = delete; |
| 3011 | __nonesuch(__nonesuch const&) = delete; |
| 3012 | void operator=(__nonesuch const&) = delete; |
| 3013 | }; |
| 3014 | #pragma GCC diagnostic pop |
| 3015 | /// @endcond |
| 3016 | |
| 3017 | #if __cplusplus >= 201703L |
| 3018 | # define __cpp_lib_is_invocable 201703L |
| 3019 | |
| 3020 | /// std::invoke_result |
| 3021 | template<typename _Functor, typename... _ArgTypes> |
| 3022 | struct invoke_result |
| 3023 | : public __invoke_result<_Functor, _ArgTypes...> |
| 3024 | { |
| 3025 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Functor>{}), |
| 3026 | "_Functor must be a complete class or an unbounded array" ); |
| 3027 | static_assert((std::__is_complete_or_unbounded( |
| 3028 | __type_identity<_ArgTypes>{}) && ...), |
| 3029 | "each argument type must be a complete class or an unbounded array" ); |
| 3030 | }; |
| 3031 | |
| 3032 | /// std::invoke_result_t |
| 3033 | template<typename _Fn, typename... _Args> |
| 3034 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; |
| 3035 | |
| 3036 | /// std::is_invocable |
| 3037 | template<typename _Fn, typename... _ArgTypes> |
| 3038 | struct is_invocable |
| 3039 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type |
| 3040 | { |
| 3041 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
| 3042 | "_Fn must be a complete class or an unbounded array" ); |
| 3043 | static_assert((std::__is_complete_or_unbounded( |
| 3044 | __type_identity<_ArgTypes>{}) && ...), |
| 3045 | "each argument type must be a complete class or an unbounded array" ); |
| 3046 | }; |
| 3047 | |
| 3048 | /// std::is_invocable_r |
| 3049 | template<typename _Ret, typename _Fn, typename... _ArgTypes> |
| 3050 | struct is_invocable_r |
| 3051 | : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type |
| 3052 | { |
| 3053 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
| 3054 | "_Fn must be a complete class or an unbounded array" ); |
| 3055 | static_assert((std::__is_complete_or_unbounded( |
| 3056 | __type_identity<_ArgTypes>{}) && ...), |
| 3057 | "each argument type must be a complete class or an unbounded array" ); |
| 3058 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), |
| 3059 | "_Ret must be a complete class or an unbounded array" ); |
| 3060 | }; |
| 3061 | |
| 3062 | /// std::is_nothrow_invocable |
| 3063 | template<typename _Fn, typename... _ArgTypes> |
| 3064 | struct is_nothrow_invocable |
| 3065 | : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, |
| 3066 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
| 3067 | { |
| 3068 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
| 3069 | "_Fn must be a complete class or an unbounded array" ); |
| 3070 | static_assert((std::__is_complete_or_unbounded( |
| 3071 | __type_identity<_ArgTypes>{}) && ...), |
| 3072 | "each argument type must be a complete class or an unbounded array" ); |
| 3073 | }; |
| 3074 | |
| 3075 | /// @cond undocumented |
| 3076 | template<typename _Result, typename _Ret, typename = void> |
| 3077 | struct __is_nt_invocable_impl : false_type { }; |
| 3078 | |
| 3079 | template<typename _Result, typename _Ret> |
| 3080 | struct __is_nt_invocable_impl<_Result, _Ret, |
| 3081 | __void_t<typename _Result::type>> |
| 3082 | : __or_<is_void<_Ret>, |
| 3083 | __is_nothrow_convertible<typename _Result::type, _Ret>> |
| 3084 | { }; |
| 3085 | /// @endcond |
| 3086 | |
| 3087 | /// std::is_nothrow_invocable_r |
| 3088 | template<typename _Ret, typename _Fn, typename... _ArgTypes> |
| 3089 | struct is_nothrow_invocable_r |
| 3090 | : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, |
| 3091 | __call_is_nothrow_<_Fn, _ArgTypes...>>::type |
| 3092 | { |
| 3093 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), |
| 3094 | "_Fn must be a complete class or an unbounded array" ); |
| 3095 | static_assert((std::__is_complete_or_unbounded( |
| 3096 | __type_identity<_ArgTypes>{}) && ...), |
| 3097 | "each argument type must be a complete class or an unbounded array" ); |
| 3098 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), |
| 3099 | "_Ret must be a complete class or an unbounded array" ); |
| 3100 | }; |
| 3101 | #endif // C++17 |
| 3102 | |
| 3103 | #if __cplusplus >= 201703L |
| 3104 | # define __cpp_lib_type_trait_variable_templates 201510L |
| 3105 | /** |
| 3106 | * @defgroup variable_templates Variable templates for type traits |
| 3107 | * @ingroup metaprogramming |
| 3108 | * |
| 3109 | * Each variable `is_xxx_v<T>` is a boolean constant with the same value |
| 3110 | * as the `value` member of the corresponding type trait `is_xxx<T>`. |
| 3111 | * |
| 3112 | * @since C++17 unless noted otherwise. |
| 3113 | */ |
| 3114 | |
| 3115 | /** |
| 3116 | * @{ |
| 3117 | * @ingroup variable_templates |
| 3118 | */ |
| 3119 | template <typename _Tp> |
| 3120 | inline constexpr bool is_void_v = is_void<_Tp>::value; |
| 3121 | template <typename _Tp> |
| 3122 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; |
| 3123 | template <typename _Tp> |
| 3124 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; |
| 3125 | template <typename _Tp> |
| 3126 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; |
| 3127 | template <typename _Tp> |
| 3128 | inline constexpr bool is_array_v = is_array<_Tp>::value; |
| 3129 | template <typename _Tp> |
| 3130 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; |
| 3131 | template <typename _Tp> |
| 3132 | inline constexpr bool is_lvalue_reference_v = |
| 3133 | is_lvalue_reference<_Tp>::value; |
| 3134 | template <typename _Tp> |
| 3135 | inline constexpr bool is_rvalue_reference_v = |
| 3136 | is_rvalue_reference<_Tp>::value; |
| 3137 | template <typename _Tp> |
| 3138 | inline constexpr bool is_member_object_pointer_v = |
| 3139 | is_member_object_pointer<_Tp>::value; |
| 3140 | template <typename _Tp> |
| 3141 | inline constexpr bool is_member_function_pointer_v = |
| 3142 | is_member_function_pointer<_Tp>::value; |
| 3143 | template <typename _Tp> |
| 3144 | inline constexpr bool is_enum_v = is_enum<_Tp>::value; |
| 3145 | template <typename _Tp> |
| 3146 | inline constexpr bool is_union_v = is_union<_Tp>::value; |
| 3147 | template <typename _Tp> |
| 3148 | inline constexpr bool is_class_v = is_class<_Tp>::value; |
| 3149 | template <typename _Tp> |
| 3150 | inline constexpr bool is_function_v = is_function<_Tp>::value; |
| 3151 | template <typename _Tp> |
| 3152 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; |
| 3153 | template <typename _Tp> |
| 3154 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; |
| 3155 | template <typename _Tp> |
| 3156 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; |
| 3157 | template <typename _Tp> |
| 3158 | inline constexpr bool is_object_v = is_object<_Tp>::value; |
| 3159 | template <typename _Tp> |
| 3160 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; |
| 3161 | template <typename _Tp> |
| 3162 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; |
| 3163 | template <typename _Tp> |
| 3164 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; |
| 3165 | template <typename _Tp> |
| 3166 | inline constexpr bool is_const_v = is_const<_Tp>::value; |
| 3167 | template <typename _Tp> |
| 3168 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; |
| 3169 | template <typename _Tp> |
| 3170 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; |
| 3171 | template <typename _Tp> |
| 3172 | inline constexpr bool is_trivially_copyable_v = |
| 3173 | is_trivially_copyable<_Tp>::value; |
| 3174 | template <typename _Tp> |
| 3175 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; |
| 3176 | #pragma GCC diagnostic push |
| 3177 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 3178 | template <typename _Tp> |
| 3179 | _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v instead" ) |
| 3180 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; |
| 3181 | template <typename _Tp> |
| 3182 | _GLIBCXX17_DEPRECATED |
| 3183 | inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; |
| 3184 | #pragma GCC diagnostic pop |
| 3185 | template <typename _Tp> |
| 3186 | inline constexpr bool is_empty_v = is_empty<_Tp>::value; |
| 3187 | template <typename _Tp> |
| 3188 | inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; |
| 3189 | template <typename _Tp> |
| 3190 | inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; |
| 3191 | template <typename _Tp> |
| 3192 | inline constexpr bool is_final_v = is_final<_Tp>::value; |
| 3193 | template <typename _Tp> |
| 3194 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; |
| 3195 | template <typename _Tp> |
| 3196 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; |
| 3197 | template <typename _Tp, typename... _Args> |
| 3198 | inline constexpr bool is_constructible_v = |
| 3199 | is_constructible<_Tp, _Args...>::value; |
| 3200 | template <typename _Tp> |
| 3201 | inline constexpr bool is_default_constructible_v = |
| 3202 | is_default_constructible<_Tp>::value; |
| 3203 | template <typename _Tp> |
| 3204 | inline constexpr bool is_copy_constructible_v = |
| 3205 | is_copy_constructible<_Tp>::value; |
| 3206 | template <typename _Tp> |
| 3207 | inline constexpr bool is_move_constructible_v = |
| 3208 | is_move_constructible<_Tp>::value; |
| 3209 | template <typename _Tp, typename _Up> |
| 3210 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; |
| 3211 | template <typename _Tp> |
| 3212 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; |
| 3213 | template <typename _Tp> |
| 3214 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; |
| 3215 | template <typename _Tp> |
| 3216 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; |
| 3217 | template <typename _Tp, typename... _Args> |
| 3218 | inline constexpr bool is_trivially_constructible_v = |
| 3219 | is_trivially_constructible<_Tp, _Args...>::value; |
| 3220 | template <typename _Tp> |
| 3221 | inline constexpr bool is_trivially_default_constructible_v = |
| 3222 | is_trivially_default_constructible<_Tp>::value; |
| 3223 | template <typename _Tp> |
| 3224 | inline constexpr bool is_trivially_copy_constructible_v = |
| 3225 | is_trivially_copy_constructible<_Tp>::value; |
| 3226 | template <typename _Tp> |
| 3227 | inline constexpr bool is_trivially_move_constructible_v = |
| 3228 | is_trivially_move_constructible<_Tp>::value; |
| 3229 | template <typename _Tp, typename _Up> |
| 3230 | inline constexpr bool is_trivially_assignable_v = |
| 3231 | is_trivially_assignable<_Tp, _Up>::value; |
| 3232 | template <typename _Tp> |
| 3233 | inline constexpr bool is_trivially_copy_assignable_v = |
| 3234 | is_trivially_copy_assignable<_Tp>::value; |
| 3235 | template <typename _Tp> |
| 3236 | inline constexpr bool is_trivially_move_assignable_v = |
| 3237 | is_trivially_move_assignable<_Tp>::value; |
| 3238 | template <typename _Tp> |
| 3239 | inline constexpr bool is_trivially_destructible_v = |
| 3240 | is_trivially_destructible<_Tp>::value; |
| 3241 | template <typename _Tp, typename... _Args> |
| 3242 | inline constexpr bool is_nothrow_constructible_v = |
| 3243 | is_nothrow_constructible<_Tp, _Args...>::value; |
| 3244 | template <typename _Tp> |
| 3245 | inline constexpr bool is_nothrow_default_constructible_v = |
| 3246 | is_nothrow_default_constructible<_Tp>::value; |
| 3247 | template <typename _Tp> |
| 3248 | inline constexpr bool is_nothrow_copy_constructible_v = |
| 3249 | is_nothrow_copy_constructible<_Tp>::value; |
| 3250 | template <typename _Tp> |
| 3251 | inline constexpr bool is_nothrow_move_constructible_v = |
| 3252 | is_nothrow_move_constructible<_Tp>::value; |
| 3253 | template <typename _Tp, typename _Up> |
| 3254 | inline constexpr bool is_nothrow_assignable_v = |
| 3255 | is_nothrow_assignable<_Tp, _Up>::value; |
| 3256 | template <typename _Tp> |
| 3257 | inline constexpr bool is_nothrow_copy_assignable_v = |
| 3258 | is_nothrow_copy_assignable<_Tp>::value; |
| 3259 | template <typename _Tp> |
| 3260 | inline constexpr bool is_nothrow_move_assignable_v = |
| 3261 | is_nothrow_move_assignable<_Tp>::value; |
| 3262 | template <typename _Tp> |
| 3263 | inline constexpr bool is_nothrow_destructible_v = |
| 3264 | is_nothrow_destructible<_Tp>::value; |
| 3265 | template <typename _Tp> |
| 3266 | inline constexpr bool has_virtual_destructor_v = |
| 3267 | has_virtual_destructor<_Tp>::value; |
| 3268 | template <typename _Tp> |
| 3269 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; |
| 3270 | template <typename _Tp> |
| 3271 | inline constexpr size_t rank_v = rank<_Tp>::value; |
| 3272 | template <typename _Tp, unsigned _Idx = 0> |
| 3273 | inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; |
| 3274 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME |
| 3275 | template <typename _Tp, typename _Up> |
| 3276 | inline constexpr bool is_same_v = __is_same(_Tp, _Up); |
| 3277 | #else |
| 3278 | template <typename _Tp, typename _Up> |
| 3279 | inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value; |
| 3280 | #endif |
| 3281 | template <typename _Base, typename _Derived> |
| 3282 | inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; |
| 3283 | template <typename _From, typename _To> |
| 3284 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; |
| 3285 | template<typename _Fn, typename... _Args> |
| 3286 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; |
| 3287 | template<typename _Fn, typename... _Args> |
| 3288 | inline constexpr bool is_nothrow_invocable_v |
| 3289 | = is_nothrow_invocable<_Fn, _Args...>::value; |
| 3290 | template<typename _Ret, typename _Fn, typename... _Args> |
| 3291 | inline constexpr bool is_invocable_r_v |
| 3292 | = is_invocable_r<_Ret, _Fn, _Args...>::value; |
| 3293 | template<typename _Ret, typename _Fn, typename... _Args> |
| 3294 | inline constexpr bool is_nothrow_invocable_r_v |
| 3295 | = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; |
| 3296 | /// @} |
| 3297 | |
| 3298 | #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP |
| 3299 | # define __cpp_lib_has_unique_object_representations 201606L |
| 3300 | /// has_unique_object_representations |
| 3301 | /// @since C++17 |
| 3302 | template<typename _Tp> |
| 3303 | struct has_unique_object_representations |
| 3304 | : bool_constant<__has_unique_object_representations( |
| 3305 | remove_cv_t<remove_all_extents_t<_Tp>> |
| 3306 | )> |
| 3307 | { |
| 3308 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), |
| 3309 | "template argument must be a complete class or an unbounded array" ); |
| 3310 | }; |
| 3311 | |
| 3312 | /// @ingroup variable_templates |
| 3313 | template<typename _Tp> |
| 3314 | inline constexpr bool has_unique_object_representations_v |
| 3315 | = has_unique_object_representations<_Tp>::value; |
| 3316 | #endif |
| 3317 | |
| 3318 | #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE |
| 3319 | # define __cpp_lib_is_aggregate 201703L |
| 3320 | /// is_aggregate |
| 3321 | /// @since C++17 |
| 3322 | template<typename _Tp> |
| 3323 | struct is_aggregate |
| 3324 | : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> |
| 3325 | { }; |
| 3326 | |
| 3327 | /// @ingroup variable_templates |
| 3328 | template<typename _Tp> |
| 3329 | inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; |
| 3330 | #endif |
| 3331 | #endif // C++17 |
| 3332 | |
| 3333 | #if __cplusplus >= 202002L |
| 3334 | |
| 3335 | /** * Remove references and cv-qualifiers. |
| 3336 | * @since C++20 |
| 3337 | * @{ |
| 3338 | */ |
| 3339 | #define __cpp_lib_remove_cvref 201711L |
| 3340 | |
| 3341 | template<typename _Tp> |
| 3342 | struct remove_cvref |
| 3343 | : remove_cv<_Tp> |
| 3344 | { }; |
| 3345 | |
| 3346 | template<typename _Tp> |
| 3347 | struct remove_cvref<_Tp&> |
| 3348 | : remove_cv<_Tp> |
| 3349 | { }; |
| 3350 | |
| 3351 | template<typename _Tp> |
| 3352 | struct remove_cvref<_Tp&&> |
| 3353 | : remove_cv<_Tp> |
| 3354 | { }; |
| 3355 | |
| 3356 | template<typename _Tp> |
| 3357 | using remove_cvref_t = typename remove_cvref<_Tp>::type; |
| 3358 | /// @} |
| 3359 | |
| 3360 | /** * Identity metafunction. |
| 3361 | * @since C++20 |
| 3362 | * @{ |
| 3363 | */ |
| 3364 | #define __cpp_lib_type_identity 201806L |
| 3365 | template<typename _Tp> |
| 3366 | struct type_identity { using type = _Tp; }; |
| 3367 | |
| 3368 | template<typename _Tp> |
| 3369 | using type_identity_t = typename type_identity<_Tp>::type; |
| 3370 | /// @} |
| 3371 | |
| 3372 | #define __cpp_lib_unwrap_ref 201811L |
| 3373 | |
| 3374 | /** Unwrap a reference_wrapper |
| 3375 | * @since C++20 |
| 3376 | * @{ |
| 3377 | */ |
| 3378 | template<typename _Tp> |
| 3379 | struct unwrap_reference { using type = _Tp; }; |
| 3380 | |
| 3381 | template<typename _Tp> |
| 3382 | struct unwrap_reference<reference_wrapper<_Tp>> { using type = _Tp&; }; |
| 3383 | |
| 3384 | template<typename _Tp> |
| 3385 | using unwrap_reference_t = typename unwrap_reference<_Tp>::type; |
| 3386 | /// @} |
| 3387 | |
| 3388 | /** Decay type and if it's a reference_wrapper, unwrap it |
| 3389 | * @since C++20 |
| 3390 | * @{ |
| 3391 | */ |
| 3392 | template<typename _Tp> |
| 3393 | struct unwrap_ref_decay { using type = unwrap_reference_t<decay_t<_Tp>>; }; |
| 3394 | |
| 3395 | template<typename _Tp> |
| 3396 | using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; |
| 3397 | /// @} |
| 3398 | |
| 3399 | #define __cpp_lib_bounded_array_traits 201902L |
| 3400 | |
| 3401 | /// True for a type that is an array of known bound. |
| 3402 | /// @since C++20 |
| 3403 | template<typename _Tp> |
| 3404 | struct is_bounded_array |
| 3405 | : public __is_array_known_bounds<_Tp> |
| 3406 | { }; |
| 3407 | |
| 3408 | /// True for a type that is an array of unknown bound. |
| 3409 | /// @since C++20 |
| 3410 | template<typename _Tp> |
| 3411 | struct is_unbounded_array |
| 3412 | : public __is_array_unknown_bounds<_Tp> |
| 3413 | { }; |
| 3414 | |
| 3415 | /// @ingroup variable_templates |
| 3416 | /// @since C++20 |
| 3417 | template<typename _Tp> |
| 3418 | inline constexpr bool is_bounded_array_v |
| 3419 | = is_bounded_array<_Tp>::value; |
| 3420 | |
| 3421 | /// @ingroup variable_templates |
| 3422 | /// @since C++20 |
| 3423 | template<typename _Tp> |
| 3424 | inline constexpr bool is_unbounded_array_v |
| 3425 | = is_unbounded_array<_Tp>::value; |
| 3426 | |
| 3427 | #if __has_builtin(__is_layout_compatible) |
| 3428 | |
| 3429 | /// @since C++20 |
| 3430 | template<typename _Tp, typename _Up> |
| 3431 | struct is_layout_compatible |
| 3432 | : bool_constant<__is_layout_compatible(_Tp, _Up)> |
| 3433 | { }; |
| 3434 | |
| 3435 | /// @ingroup variable_templates |
| 3436 | /// @since C++20 |
| 3437 | template<typename _Tp, typename _Up> |
| 3438 | constexpr bool is_layout_compatible_v |
| 3439 | = __is_layout_compatible(_Tp, _Up); |
| 3440 | |
| 3441 | #if __has_builtin(__builtin_is_corresponding_member) |
| 3442 | #define __cpp_lib_is_layout_compatible 201907L |
| 3443 | |
| 3444 | /// @since C++20 |
| 3445 | template<typename _S1, typename _S2, typename _M1, typename _M2> |
| 3446 | constexpr bool |
| 3447 | is_corresponding_member(_M1 _S1::*__m1, _M2 _S2::*__m2) noexcept |
| 3448 | { return __builtin_is_corresponding_member(__m1, __m2); } |
| 3449 | #endif |
| 3450 | #endif |
| 3451 | |
| 3452 | #if __has_builtin(__is_pointer_interconvertible_base_of) |
| 3453 | /// True if `_Derived` is standard-layout and has a base class of type `_Base` |
| 3454 | /// @since C++20 |
| 3455 | template<typename _Base, typename _Derived> |
| 3456 | struct is_pointer_interconvertible_base_of |
| 3457 | : bool_constant<__is_pointer_interconvertible_base_of(_Base, _Derived)> |
| 3458 | { }; |
| 3459 | |
| 3460 | /// @ingroup variable_templates |
| 3461 | /// @since C++20 |
| 3462 | template<typename _Base, typename _Derived> |
| 3463 | constexpr bool is_pointer_interconvertible_base_of_v |
| 3464 | = __is_pointer_interconvertible_base_of(_Base, _Derived); |
| 3465 | |
| 3466 | #if __has_builtin(__builtin_is_pointer_interconvertible_with_class) |
| 3467 | #define __cpp_lib_is_pointer_interconvertible 201907L |
| 3468 | |
| 3469 | /// True if `__mp` points to the first member of a standard-layout type |
| 3470 | /// @returns true if `s.*__mp` is pointer-interconvertible with `s` |
| 3471 | /// @since C++20 |
| 3472 | template<typename _Tp, typename _Mem> |
| 3473 | constexpr bool |
| 3474 | is_pointer_interconvertible_with_class(_Mem _Tp::*__mp) noexcept |
| 3475 | { return __builtin_is_pointer_interconvertible_with_class(__mp); } |
| 3476 | #endif |
| 3477 | #endif |
| 3478 | |
| 3479 | #if __cplusplus > 202002L |
| 3480 | #define __cpp_lib_is_scoped_enum 202011L |
| 3481 | |
| 3482 | /// True if the type is a scoped enumeration type. |
| 3483 | /// @since C++23 |
| 3484 | |
| 3485 | template<typename _Tp> |
| 3486 | struct is_scoped_enum |
| 3487 | : false_type |
| 3488 | { }; |
| 3489 | |
| 3490 | template<typename _Tp> |
| 3491 | requires __is_enum(_Tp) |
| 3492 | && requires(_Tp __t) { __t = __t; } // fails if incomplete |
| 3493 | struct is_scoped_enum<_Tp> |
| 3494 | : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }> |
| 3495 | { }; |
| 3496 | |
| 3497 | // FIXME remove this partial specialization and use remove_cv_t<_Tp> above |
| 3498 | // when PR c++/99968 is fixed. |
| 3499 | template<typename _Tp> |
| 3500 | requires __is_enum(_Tp) |
| 3501 | && requires(_Tp __t) { __t = __t; } // fails if incomplete |
| 3502 | struct is_scoped_enum<const _Tp> |
| 3503 | : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }> |
| 3504 | { }; |
| 3505 | |
| 3506 | /// @ingroup variable_templates |
| 3507 | /// @since C++23 |
| 3508 | template<typename _Tp> |
| 3509 | inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; |
| 3510 | |
| 3511 | #endif // C++23 |
| 3512 | |
| 3513 | #if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED |
| 3514 | #define __cpp_lib_is_constant_evaluated 201811L |
| 3515 | |
| 3516 | /// Returns true only when called during constant evaluation. |
| 3517 | /// @since C++20 |
| 3518 | constexpr inline bool |
| 3519 | is_constant_evaluated() noexcept |
| 3520 | { |
| 3521 | #if __cpp_if_consteval >= 202106L |
| 3522 | if consteval { return true; } else { return false; } |
| 3523 | #else |
| 3524 | return __builtin_is_constant_evaluated(); |
| 3525 | #endif |
| 3526 | } |
| 3527 | #endif |
| 3528 | |
| 3529 | /// @cond undocumented |
| 3530 | template<typename _From, typename _To> |
| 3531 | using __copy_cv = typename __match_cv_qualifiers<_From, _To>::__type; |
| 3532 | |
| 3533 | template<typename _Xp, typename _Yp> |
| 3534 | using __cond_res |
| 3535 | = decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); |
| 3536 | |
| 3537 | template<typename _Ap, typename _Bp, typename = void> |
| 3538 | struct __common_ref_impl |
| 3539 | { }; |
| 3540 | |
| 3541 | // [meta.trans.other], COMMON-REF(A, B) |
| 3542 | template<typename _Ap, typename _Bp> |
| 3543 | using __common_ref = typename __common_ref_impl<_Ap, _Bp>::type; |
| 3544 | |
| 3545 | // COND-RES(COPYCV(X, Y) &, COPYCV(Y, X) &) |
| 3546 | template<typename _Xp, typename _Yp> |
| 3547 | using __condres_cvref |
| 3548 | = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>; |
| 3549 | |
| 3550 | // If A and B are both lvalue reference types, ... |
| 3551 | template<typename _Xp, typename _Yp> |
| 3552 | struct __common_ref_impl<_Xp&, _Yp&, __void_t<__condres_cvref<_Xp, _Yp>>> |
| 3553 | : enable_if<is_reference_v<__condres_cvref<_Xp, _Yp>>, |
| 3554 | __condres_cvref<_Xp, _Yp>> |
| 3555 | { }; |
| 3556 | |
| 3557 | // let C be remove_reference_t<COMMON-REF(X&, Y&)>&& |
| 3558 | template<typename _Xp, typename _Yp> |
| 3559 | using __common_ref_C = remove_reference_t<__common_ref<_Xp&, _Yp&>>&&; |
| 3560 | |
| 3561 | // If A and B are both rvalue reference types, ... |
| 3562 | template<typename _Xp, typename _Yp> |
| 3563 | struct __common_ref_impl<_Xp&&, _Yp&&, |
| 3564 | _Require<is_convertible<_Xp&&, __common_ref_C<_Xp, _Yp>>, |
| 3565 | is_convertible<_Yp&&, __common_ref_C<_Xp, _Yp>>>> |
| 3566 | { using type = __common_ref_C<_Xp, _Yp>; }; |
| 3567 | |
| 3568 | // let D be COMMON-REF(const X&, Y&) |
| 3569 | template<typename _Xp, typename _Yp> |
| 3570 | using __common_ref_D = __common_ref<const _Xp&, _Yp&>; |
| 3571 | |
| 3572 | // If A is an rvalue reference and B is an lvalue reference, ... |
| 3573 | template<typename _Xp, typename _Yp> |
| 3574 | struct __common_ref_impl<_Xp&&, _Yp&, |
| 3575 | _Require<is_convertible<_Xp&&, __common_ref_D<_Xp, _Yp>>>> |
| 3576 | { using type = __common_ref_D<_Xp, _Yp>; }; |
| 3577 | |
| 3578 | // If A is an lvalue reference and B is an rvalue reference, ... |
| 3579 | template<typename _Xp, typename _Yp> |
| 3580 | struct __common_ref_impl<_Xp&, _Yp&&> |
| 3581 | : __common_ref_impl<_Yp&&, _Xp&> |
| 3582 | { }; |
| 3583 | /// @endcond |
| 3584 | |
| 3585 | template<typename _Tp, typename _Up, |
| 3586 | template<typename> class _TQual, template<typename> class _UQual> |
| 3587 | struct basic_common_reference |
| 3588 | { }; |
| 3589 | |
| 3590 | /// @cond undocumented |
| 3591 | template<typename _Tp> |
| 3592 | struct __xref |
| 3593 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>; }; |
| 3594 | |
| 3595 | template<typename _Tp> |
| 3596 | struct __xref<_Tp&> |
| 3597 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&; }; |
| 3598 | |
| 3599 | template<typename _Tp> |
| 3600 | struct __xref<_Tp&&> |
| 3601 | { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&&; }; |
| 3602 | |
| 3603 | template<typename _Tp1, typename _Tp2> |
| 3604 | using __basic_common_ref |
| 3605 | = typename basic_common_reference<remove_cvref_t<_Tp1>, |
| 3606 | remove_cvref_t<_Tp2>, |
| 3607 | __xref<_Tp1>::template __type, |
| 3608 | __xref<_Tp2>::template __type>::type; |
| 3609 | /// @endcond |
| 3610 | |
| 3611 | template<typename... _Tp> |
| 3612 | struct common_reference; |
| 3613 | |
| 3614 | template<typename... _Tp> |
| 3615 | using common_reference_t = typename common_reference<_Tp...>::type; |
| 3616 | |
| 3617 | // If sizeof...(T) is zero, there shall be no member type. |
| 3618 | template<> |
| 3619 | struct common_reference<> |
| 3620 | { }; |
| 3621 | |
| 3622 | // If sizeof...(T) is one ... |
| 3623 | template<typename _Tp0> |
| 3624 | struct common_reference<_Tp0> |
| 3625 | { using type = _Tp0; }; |
| 3626 | |
| 3627 | /// @cond undocumented |
| 3628 | template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void> |
| 3629 | struct __common_reference_impl |
| 3630 | : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1> |
| 3631 | { }; |
| 3632 | |
| 3633 | // If sizeof...(T) is two ... |
| 3634 | template<typename _Tp1, typename _Tp2> |
| 3635 | struct common_reference<_Tp1, _Tp2> |
| 3636 | : __common_reference_impl<_Tp1, _Tp2> |
| 3637 | { }; |
| 3638 | |
| 3639 | // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ... |
| 3640 | template<typename _Tp1, typename _Tp2> |
| 3641 | struct __common_reference_impl<_Tp1&, _Tp2&, 1, |
| 3642 | void_t<__common_ref<_Tp1&, _Tp2&>>> |
| 3643 | { using type = __common_ref<_Tp1&, _Tp2&>; }; |
| 3644 | |
| 3645 | template<typename _Tp1, typename _Tp2> |
| 3646 | struct __common_reference_impl<_Tp1&&, _Tp2&&, 1, |
| 3647 | void_t<__common_ref<_Tp1&&, _Tp2&&>>> |
| 3648 | { using type = __common_ref<_Tp1&&, _Tp2&&>; }; |
| 3649 | |
| 3650 | template<typename _Tp1, typename _Tp2> |
| 3651 | struct __common_reference_impl<_Tp1&, _Tp2&&, 1, |
| 3652 | void_t<__common_ref<_Tp1&, _Tp2&&>>> |
| 3653 | { using type = __common_ref<_Tp1&, _Tp2&&>; }; |
| 3654 | |
| 3655 | template<typename _Tp1, typename _Tp2> |
| 3656 | struct __common_reference_impl<_Tp1&&, _Tp2&, 1, |
| 3657 | void_t<__common_ref<_Tp1&&, _Tp2&>>> |
| 3658 | { using type = __common_ref<_Tp1&&, _Tp2&>; }; |
| 3659 | |
| 3660 | // Otherwise, if basic_common_reference<...>::type is well-formed, ... |
| 3661 | template<typename _Tp1, typename _Tp2> |
| 3662 | struct __common_reference_impl<_Tp1, _Tp2, 2, |
| 3663 | void_t<__basic_common_ref<_Tp1, _Tp2>>> |
| 3664 | { using type = __basic_common_ref<_Tp1, _Tp2>; }; |
| 3665 | |
| 3666 | // Otherwise, if COND-RES(T1, T2) is well-formed, ... |
| 3667 | template<typename _Tp1, typename _Tp2> |
| 3668 | struct __common_reference_impl<_Tp1, _Tp2, 3, |
| 3669 | void_t<__cond_res<_Tp1, _Tp2>>> |
| 3670 | { using type = __cond_res<_Tp1, _Tp2>; }; |
| 3671 | |
| 3672 | // Otherwise, if common_type_t<T1, T2> is well-formed, ... |
| 3673 | template<typename _Tp1, typename _Tp2> |
| 3674 | struct __common_reference_impl<_Tp1, _Tp2, 4, |
| 3675 | void_t<common_type_t<_Tp1, _Tp2>>> |
| 3676 | { using type = common_type_t<_Tp1, _Tp2>; }; |
| 3677 | |
| 3678 | // Otherwise, there shall be no member type. |
| 3679 | template<typename _Tp1, typename _Tp2> |
| 3680 | struct __common_reference_impl<_Tp1, _Tp2, 5, void> |
| 3681 | { }; |
| 3682 | |
| 3683 | // Otherwise, if sizeof...(T) is greater than two, ... |
| 3684 | template<typename _Tp1, typename _Tp2, typename... _Rest> |
| 3685 | struct common_reference<_Tp1, _Tp2, _Rest...> |
| 3686 | : __common_type_fold<common_reference<_Tp1, _Tp2>, |
| 3687 | __common_type_pack<_Rest...>> |
| 3688 | { }; |
| 3689 | |
| 3690 | // Reuse __common_type_fold for common_reference<T1, T2, Rest...> |
| 3691 | template<typename _Tp1, typename _Tp2, typename... _Rest> |
| 3692 | struct __common_type_fold<common_reference<_Tp1, _Tp2>, |
| 3693 | __common_type_pack<_Rest...>, |
| 3694 | void_t<common_reference_t<_Tp1, _Tp2>>> |
| 3695 | : public common_reference<common_reference_t<_Tp1, _Tp2>, _Rest...> |
| 3696 | { }; |
| 3697 | /// @endcond |
| 3698 | |
| 3699 | #endif // C++2a |
| 3700 | |
| 3701 | /// @} group metaprogramming |
| 3702 | |
| 3703 | _GLIBCXX_END_NAMESPACE_VERSION |
| 3704 | } // namespace std |
| 3705 | |
| 3706 | #endif // C++11 |
| 3707 | |
| 3708 | #endif // _GLIBCXX_TYPE_TRAITS |
| 3709 | |