libstdc++
|
00001 // C++11 <type_traits> -*- C++ -*- 00002 00003 // Copyright (C) 2007-2019 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file include/type_traits 00026 * This is a Standard C++ Library header. 00027 */ 00028 00029 #ifndef _GLIBCXX_TYPE_TRAITS 00030 #define _GLIBCXX_TYPE_TRAITS 1 00031 00032 #pragma GCC system_header 00033 00034 #if __cplusplus < 201103L 00035 # include <bits/c++0x_warning.h> 00036 #else 00037 00038 #include <bits/c++config.h> 00039 00040 namespace std _GLIBCXX_VISIBILITY(default) 00041 { 00042 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00043 00044 /** 00045 * @defgroup metaprogramming Metaprogramming 00046 * @ingroup utilities 00047 * 00048 * Template utilities for compile-time introspection and modification, 00049 * including type classification traits, type property inspection traits 00050 * and type transformation traits. 00051 * 00052 * @{ 00053 */ 00054 00055 /// integral_constant 00056 template<typename _Tp, _Tp __v> 00057 struct integral_constant 00058 { 00059 static constexpr _Tp value = __v; 00060 typedef _Tp value_type; 00061 typedef integral_constant<_Tp, __v> type; 00062 constexpr operator value_type() const noexcept { return value; } 00063 #if __cplusplus > 201103L 00064 00065 #define __cpp_lib_integral_constant_callable 201304 00066 00067 constexpr value_type operator()() const noexcept { return value; } 00068 #endif 00069 }; 00070 00071 template<typename _Tp, _Tp __v> 00072 constexpr _Tp integral_constant<_Tp, __v>::value; 00073 00074 /// The type used as a compile-time boolean with true value. 00075 typedef integral_constant<bool, true> true_type; 00076 00077 /// The type used as a compile-time boolean with false value. 00078 typedef integral_constant<bool, false> false_type; 00079 00080 template<bool __v> 00081 using __bool_constant = integral_constant<bool, __v>; 00082 00083 #if __cplusplus > 201402L 00084 # define __cpp_lib_bool_constant 201505 00085 template<bool __v> 00086 using bool_constant = integral_constant<bool, __v>; 00087 #endif 00088 00089 // Meta programming helper types. 00090 00091 template<bool, typename, typename> 00092 struct conditional; 00093 00094 template<typename...> 00095 struct __or_; 00096 00097 template<> 00098 struct __or_<> 00099 : public false_type 00100 { }; 00101 00102 template<typename _B1> 00103 struct __or_<_B1> 00104 : public _B1 00105 { }; 00106 00107 template<typename _B1, typename _B2> 00108 struct __or_<_B1, _B2> 00109 : public conditional<_B1::value, _B1, _B2>::type 00110 { }; 00111 00112 template<typename _B1, typename _B2, typename _B3, typename... _Bn> 00113 struct __or_<_B1, _B2, _B3, _Bn...> 00114 : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type 00115 { }; 00116 00117 template<typename...> 00118 struct __and_; 00119 00120 template<> 00121 struct __and_<> 00122 : public true_type 00123 { }; 00124 00125 template<typename _B1> 00126 struct __and_<_B1> 00127 : public _B1 00128 { }; 00129 00130 template<typename _B1, typename _B2> 00131 struct __and_<_B1, _B2> 00132 : public conditional<_B1::value, _B2, _B1>::type 00133 { }; 00134 00135 template<typename _B1, typename _B2, typename _B3, typename... _Bn> 00136 struct __and_<_B1, _B2, _B3, _Bn...> 00137 : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type 00138 { }; 00139 00140 template<typename _Pp> 00141 struct __not_ 00142 : public __bool_constant<!bool(_Pp::value)> 00143 { }; 00144 00145 #if __cplusplus >= 201703L 00146 00147 template<typename... _Bn> 00148 inline constexpr bool __or_v = __or_<_Bn...>::value; 00149 template<typename... _Bn> 00150 inline constexpr bool __and_v = __and_<_Bn...>::value; 00151 00152 #define __cpp_lib_logical_traits 201510 00153 00154 template<typename... _Bn> 00155 struct conjunction 00156 : __and_<_Bn...> 00157 { }; 00158 00159 template<typename... _Bn> 00160 struct disjunction 00161 : __or_<_Bn...> 00162 { }; 00163 00164 template<typename _Pp> 00165 struct negation 00166 : __not_<_Pp> 00167 { }; 00168 00169 template<typename... _Bn> 00170 inline constexpr bool conjunction_v = conjunction<_Bn...>::value; 00171 00172 template<typename... _Bn> 00173 inline constexpr bool disjunction_v = disjunction<_Bn...>::value; 00174 00175 template<typename _Pp> 00176 inline constexpr bool negation_v = negation<_Pp>::value; 00177 00178 #endif // C++17 00179 00180 // For several sfinae-friendly trait implementations we transport both the 00181 // result information (as the member type) and the failure information (no 00182 // member type). This is very similar to std::enable_if, but we cannot use 00183 // them, because we need to derive from them as an implementation detail. 00184 00185 template<typename _Tp> 00186 struct __success_type 00187 { typedef _Tp type; }; 00188 00189 struct __failure_type 00190 { }; 00191 00192 // Primary type categories. 00193 00194 template<typename> 00195 struct remove_cv; 00196 00197 template<typename> 00198 struct __is_void_helper 00199 : public false_type { }; 00200 00201 template<> 00202 struct __is_void_helper<void> 00203 : public true_type { }; 00204 00205 /// is_void 00206 template<typename _Tp> 00207 struct is_void 00208 : public __is_void_helper<typename remove_cv<_Tp>::type>::type 00209 { }; 00210 00211 template<typename> 00212 struct __is_integral_helper 00213 : public false_type { }; 00214 00215 template<> 00216 struct __is_integral_helper<bool> 00217 : public true_type { }; 00218 00219 template<> 00220 struct __is_integral_helper<char> 00221 : public true_type { }; 00222 00223 template<> 00224 struct __is_integral_helper<signed char> 00225 : public true_type { }; 00226 00227 template<> 00228 struct __is_integral_helper<unsigned char> 00229 : public true_type { }; 00230 00231 #ifdef _GLIBCXX_USE_WCHAR_T 00232 template<> 00233 struct __is_integral_helper<wchar_t> 00234 : public true_type { }; 00235 #endif 00236 00237 #ifdef _GLIBCXX_USE_CHAR8_T 00238 template<> 00239 struct __is_integral_helper<char8_t> 00240 : public true_type { }; 00241 #endif 00242 00243 template<> 00244 struct __is_integral_helper<char16_t> 00245 : public true_type { }; 00246 00247 template<> 00248 struct __is_integral_helper<char32_t> 00249 : public true_type { }; 00250 00251 template<> 00252 struct __is_integral_helper<short> 00253 : public true_type { }; 00254 00255 template<> 00256 struct __is_integral_helper<unsigned short> 00257 : public true_type { }; 00258 00259 template<> 00260 struct __is_integral_helper<int> 00261 : public true_type { }; 00262 00263 template<> 00264 struct __is_integral_helper<unsigned int> 00265 : public true_type { }; 00266 00267 template<> 00268 struct __is_integral_helper<long> 00269 : public true_type { }; 00270 00271 template<> 00272 struct __is_integral_helper<unsigned long> 00273 : public true_type { }; 00274 00275 template<> 00276 struct __is_integral_helper<long long> 00277 : public true_type { }; 00278 00279 template<> 00280 struct __is_integral_helper<unsigned long long> 00281 : public true_type { }; 00282 00283 // Conditionalizing on __STRICT_ANSI__ here will break any port that 00284 // uses one of these types for size_t. 00285 #if defined(__GLIBCXX_TYPE_INT_N_0) 00286 template<> 00287 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> 00288 : public true_type { }; 00289 00290 template<> 00291 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> 00292 : public true_type { }; 00293 #endif 00294 #if defined(__GLIBCXX_TYPE_INT_N_1) 00295 template<> 00296 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> 00297 : public true_type { }; 00298 00299 template<> 00300 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> 00301 : public true_type { }; 00302 #endif 00303 #if defined(__GLIBCXX_TYPE_INT_N_2) 00304 template<> 00305 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> 00306 : public true_type { }; 00307 00308 template<> 00309 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> 00310 : public true_type { }; 00311 #endif 00312 #if defined(__GLIBCXX_TYPE_INT_N_3) 00313 template<> 00314 struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> 00315 : public true_type { }; 00316 00317 template<> 00318 struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> 00319 : public true_type { }; 00320 #endif 00321 00322 /// is_integral 00323 template<typename _Tp> 00324 struct is_integral 00325 : public __is_integral_helper<typename remove_cv<_Tp>::type>::type 00326 { }; 00327 00328 template<typename> 00329 struct __is_floating_point_helper 00330 : public false_type { }; 00331 00332 template<> 00333 struct __is_floating_point_helper<float> 00334 : public true_type { }; 00335 00336 template<> 00337 struct __is_floating_point_helper<double> 00338 : public true_type { }; 00339 00340 template<> 00341 struct __is_floating_point_helper<long double> 00342 : public true_type { }; 00343 00344 #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) 00345 template<> 00346 struct __is_floating_point_helper<__float128> 00347 : public true_type { }; 00348 #endif 00349 00350 /// is_floating_point 00351 template<typename _Tp> 00352 struct is_floating_point 00353 : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type 00354 { }; 00355 00356 /// is_array 00357 template<typename> 00358 struct is_array 00359 : public false_type { }; 00360 00361 template<typename _Tp, std::size_t _Size> 00362 struct is_array<_Tp[_Size]> 00363 : public true_type { }; 00364 00365 template<typename _Tp> 00366 struct is_array<_Tp[]> 00367 : public true_type { }; 00368 00369 template<typename> 00370 struct __is_pointer_helper 00371 : public false_type { }; 00372 00373 template<typename _Tp> 00374 struct __is_pointer_helper<_Tp*> 00375 : public true_type { }; 00376 00377 /// is_pointer 00378 template<typename _Tp> 00379 struct is_pointer 00380 : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type 00381 { }; 00382 00383 /// is_lvalue_reference 00384 template<typename> 00385 struct is_lvalue_reference 00386 : public false_type { }; 00387 00388 template<typename _Tp> 00389 struct is_lvalue_reference<_Tp&> 00390 : public true_type { }; 00391 00392 /// is_rvalue_reference 00393 template<typename> 00394 struct is_rvalue_reference 00395 : public false_type { }; 00396 00397 template<typename _Tp> 00398 struct is_rvalue_reference<_Tp&&> 00399 : public true_type { }; 00400 00401 template<typename> 00402 struct is_function; 00403 00404 template<typename> 00405 struct __is_member_object_pointer_helper 00406 : public false_type { }; 00407 00408 template<typename _Tp, typename _Cp> 00409 struct __is_member_object_pointer_helper<_Tp _Cp::*> 00410 : public __not_<is_function<_Tp>>::type { }; 00411 00412 /// is_member_object_pointer 00413 template<typename _Tp> 00414 struct is_member_object_pointer 00415 : public __is_member_object_pointer_helper< 00416 typename remove_cv<_Tp>::type>::type 00417 { }; 00418 00419 template<typename> 00420 struct __is_member_function_pointer_helper 00421 : public false_type { }; 00422 00423 template<typename _Tp, typename _Cp> 00424 struct __is_member_function_pointer_helper<_Tp _Cp::*> 00425 : public is_function<_Tp>::type { }; 00426 00427 /// is_member_function_pointer 00428 template<typename _Tp> 00429 struct is_member_function_pointer 00430 : public __is_member_function_pointer_helper< 00431 typename remove_cv<_Tp>::type>::type 00432 { }; 00433 00434 /// is_enum 00435 template<typename _Tp> 00436 struct is_enum 00437 : public integral_constant<bool, __is_enum(_Tp)> 00438 { }; 00439 00440 /// is_union 00441 template<typename _Tp> 00442 struct is_union 00443 : public integral_constant<bool, __is_union(_Tp)> 00444 { }; 00445 00446 /// is_class 00447 template<typename _Tp> 00448 struct is_class 00449 : public integral_constant<bool, __is_class(_Tp)> 00450 { }; 00451 00452 /// is_function 00453 template<typename> 00454 struct is_function 00455 : public false_type { }; 00456 00457 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00458 struct is_function<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL> 00459 : public true_type { }; 00460 00461 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00462 struct is_function<_Res(_ArgTypes...) & _GLIBCXX_NOEXCEPT_QUAL> 00463 : public true_type { }; 00464 00465 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00466 struct is_function<_Res(_ArgTypes...) && _GLIBCXX_NOEXCEPT_QUAL> 00467 : public true_type { }; 00468 00469 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00470 struct is_function<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL> 00471 : public true_type { }; 00472 00473 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00474 struct is_function<_Res(_ArgTypes......) & _GLIBCXX_NOEXCEPT_QUAL> 00475 : public true_type { }; 00476 00477 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00478 struct is_function<_Res(_ArgTypes......) && _GLIBCXX_NOEXCEPT_QUAL> 00479 : public true_type { }; 00480 00481 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00482 struct is_function<_Res(_ArgTypes...) const _GLIBCXX_NOEXCEPT_QUAL> 00483 : public true_type { }; 00484 00485 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00486 struct is_function<_Res(_ArgTypes...) const & _GLIBCXX_NOEXCEPT_QUAL> 00487 : public true_type { }; 00488 00489 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00490 struct is_function<_Res(_ArgTypes...) const && _GLIBCXX_NOEXCEPT_QUAL> 00491 : public true_type { }; 00492 00493 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00494 struct is_function<_Res(_ArgTypes......) const _GLIBCXX_NOEXCEPT_QUAL> 00495 : public true_type { }; 00496 00497 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00498 struct is_function<_Res(_ArgTypes......) const & _GLIBCXX_NOEXCEPT_QUAL> 00499 : public true_type { }; 00500 00501 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00502 struct is_function<_Res(_ArgTypes......) const && _GLIBCXX_NOEXCEPT_QUAL> 00503 : public true_type { }; 00504 00505 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00506 struct is_function<_Res(_ArgTypes...) volatile _GLIBCXX_NOEXCEPT_QUAL> 00507 : public true_type { }; 00508 00509 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00510 struct is_function<_Res(_ArgTypes...) volatile & _GLIBCXX_NOEXCEPT_QUAL> 00511 : public true_type { }; 00512 00513 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00514 struct is_function<_Res(_ArgTypes...) volatile && _GLIBCXX_NOEXCEPT_QUAL> 00515 : public true_type { }; 00516 00517 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00518 struct is_function<_Res(_ArgTypes......) volatile _GLIBCXX_NOEXCEPT_QUAL> 00519 : public true_type { }; 00520 00521 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00522 struct is_function<_Res(_ArgTypes......) volatile & _GLIBCXX_NOEXCEPT_QUAL> 00523 : public true_type { }; 00524 00525 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00526 struct is_function<_Res(_ArgTypes......) volatile && _GLIBCXX_NOEXCEPT_QUAL> 00527 : public true_type { }; 00528 00529 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00530 struct is_function<_Res(_ArgTypes...) const volatile _GLIBCXX_NOEXCEPT_QUAL> 00531 : public true_type { }; 00532 00533 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00534 struct is_function<_Res(_ArgTypes...) const volatile & _GLIBCXX_NOEXCEPT_QUAL> 00535 : public true_type { }; 00536 00537 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00538 struct is_function<_Res(_ArgTypes...) const volatile && _GLIBCXX_NOEXCEPT_QUAL> 00539 : public true_type { }; 00540 00541 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00542 struct is_function<_Res(_ArgTypes......) const volatile _GLIBCXX_NOEXCEPT_QUAL> 00543 : public true_type { }; 00544 00545 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00546 struct is_function<_Res(_ArgTypes......) const volatile & _GLIBCXX_NOEXCEPT_QUAL> 00547 : public true_type { }; 00548 00549 template<typename _Res, typename... _ArgTypes _GLIBCXX_NOEXCEPT_PARM> 00550 struct is_function<_Res(_ArgTypes......) const volatile && _GLIBCXX_NOEXCEPT_QUAL> 00551 : public true_type { }; 00552 00553 #define __cpp_lib_is_null_pointer 201309 00554 00555 template<typename> 00556 struct __is_null_pointer_helper 00557 : public false_type { }; 00558 00559 template<> 00560 struct __is_null_pointer_helper<std::nullptr_t> 00561 : public true_type { }; 00562 00563 /// is_null_pointer (LWG 2247). 00564 template<typename _Tp> 00565 struct is_null_pointer 00566 : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type 00567 { }; 00568 00569 /// __is_nullptr_t (extension). 00570 template<typename _Tp> 00571 struct __is_nullptr_t 00572 : public is_null_pointer<_Tp> 00573 { }; 00574 00575 // Composite type categories. 00576 00577 /// is_reference 00578 template<typename _Tp> 00579 struct is_reference 00580 : public __or_<is_lvalue_reference<_Tp>, 00581 is_rvalue_reference<_Tp>>::type 00582 { }; 00583 00584 /// is_arithmetic 00585 template<typename _Tp> 00586 struct is_arithmetic 00587 : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type 00588 { }; 00589 00590 /// is_fundamental 00591 template<typename _Tp> 00592 struct is_fundamental 00593 : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, 00594 is_null_pointer<_Tp>>::type 00595 { }; 00596 00597 /// is_object 00598 template<typename _Tp> 00599 struct is_object 00600 : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, 00601 is_void<_Tp>>>::type 00602 { }; 00603 00604 template<typename> 00605 struct is_member_pointer; 00606 00607 /// is_scalar 00608 template<typename _Tp> 00609 struct is_scalar 00610 : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, 00611 is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type 00612 { }; 00613 00614 /// is_compound 00615 template<typename _Tp> 00616 struct is_compound 00617 : public __not_<is_fundamental<_Tp>>::type { }; 00618 00619 template<typename _Tp> 00620 struct __is_member_pointer_helper 00621 : public false_type { }; 00622 00623 template<typename _Tp, typename _Cp> 00624 struct __is_member_pointer_helper<_Tp _Cp::*> 00625 : public true_type { }; 00626 00627 /// is_member_pointer 00628 template<typename _Tp> 00629 struct is_member_pointer 00630 : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type 00631 { }; 00632 00633 // Utility to detect referenceable types ([defns.referenceable]). 00634 00635 template<typename _Tp> 00636 struct __is_referenceable 00637 : public __or_<is_object<_Tp>, is_reference<_Tp>>::type 00638 { }; 00639 00640 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM> 00641 struct __is_referenceable<_Res(_Args...) _GLIBCXX_NOEXCEPT_QUAL> 00642 : public true_type 00643 { }; 00644 00645 template<typename _Res, typename... _Args _GLIBCXX_NOEXCEPT_PARM> 00646 struct __is_referenceable<_Res(_Args......) _GLIBCXX_NOEXCEPT_QUAL> 00647 : public true_type 00648 { }; 00649 00650 // Type properties. 00651 00652 /// is_const 00653 template<typename> 00654 struct is_const 00655 : public false_type { }; 00656 00657 template<typename _Tp> 00658 struct is_const<_Tp const> 00659 : public true_type { }; 00660 00661 /// is_volatile 00662 template<typename> 00663 struct is_volatile 00664 : public false_type { }; 00665 00666 template<typename _Tp> 00667 struct is_volatile<_Tp volatile> 00668 : public true_type { }; 00669 00670 /// is_trivial 00671 template<typename _Tp> 00672 struct is_trivial 00673 : public integral_constant<bool, __is_trivial(_Tp)> 00674 { }; 00675 00676 // is_trivially_copyable 00677 template<typename _Tp> 00678 struct is_trivially_copyable 00679 : public integral_constant<bool, __is_trivially_copyable(_Tp)> 00680 { }; 00681 00682 /// is_standard_layout 00683 template<typename _Tp> 00684 struct is_standard_layout 00685 : public integral_constant<bool, __is_standard_layout(_Tp)> 00686 { }; 00687 00688 /// is_pod 00689 // Could use is_standard_layout && is_trivial instead of the builtin. 00690 template<typename _Tp> 00691 struct is_pod 00692 : public integral_constant<bool, __is_pod(_Tp)> 00693 { }; 00694 00695 /// is_literal_type 00696 template<typename _Tp> 00697 struct is_literal_type 00698 : public integral_constant<bool, __is_literal_type(_Tp)> 00699 { }; 00700 00701 /// is_empty 00702 template<typename _Tp> 00703 struct is_empty 00704 : public integral_constant<bool, __is_empty(_Tp)> 00705 { }; 00706 00707 /// is_polymorphic 00708 template<typename _Tp> 00709 struct is_polymorphic 00710 : public integral_constant<bool, __is_polymorphic(_Tp)> 00711 { }; 00712 00713 #if __cplusplus >= 201402L 00714 #define __cpp_lib_is_final 201402L 00715 /// is_final 00716 template<typename _Tp> 00717 struct is_final 00718 : public integral_constant<bool, __is_final(_Tp)> 00719 { }; 00720 #endif 00721 00722 /// is_abstract 00723 template<typename _Tp> 00724 struct is_abstract 00725 : public integral_constant<bool, __is_abstract(_Tp)> 00726 { }; 00727 00728 template<typename _Tp, 00729 bool = is_arithmetic<_Tp>::value> 00730 struct __is_signed_helper 00731 : public false_type { }; 00732 00733 template<typename _Tp> 00734 struct __is_signed_helper<_Tp, true> 00735 : public integral_constant<bool, _Tp(-1) < _Tp(0)> 00736 { }; 00737 00738 /// is_signed 00739 template<typename _Tp> 00740 struct is_signed 00741 : public __is_signed_helper<_Tp>::type 00742 { }; 00743 00744 /// is_unsigned 00745 template<typename _Tp> 00746 struct is_unsigned 00747 : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> 00748 { }; 00749 00750 00751 // Destructible and constructible type properties. 00752 00753 /** 00754 * @brief Utility to simplify expressions used in unevaluated operands 00755 * @ingroup utilities 00756 */ 00757 00758 template<typename _Tp, typename _Up = _Tp&&> 00759 _Up 00760 __declval(int); 00761 00762 template<typename _Tp> 00763 _Tp 00764 __declval(long); 00765 00766 template<typename _Tp> 00767 auto declval() noexcept -> decltype(__declval<_Tp>(0)); 00768 00769 template<typename, unsigned = 0> 00770 struct extent; 00771 00772 template<typename> 00773 struct remove_all_extents; 00774 00775 template<typename _Tp> 00776 struct __is_array_known_bounds 00777 : public integral_constant<bool, (extent<_Tp>::value > 0)> 00778 { }; 00779 00780 template<typename _Tp> 00781 struct __is_array_unknown_bounds 00782 : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> 00783 { }; 00784 00785 // In N3290 is_destructible does not say anything about function 00786 // types and abstract types, see LWG 2049. This implementation 00787 // describes function types as non-destructible and all complete 00788 // object types as destructible, iff the explicit destructor 00789 // call expression is wellformed. 00790 struct __do_is_destructible_impl 00791 { 00792 template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> 00793 static true_type __test(int); 00794 00795 template<typename> 00796 static false_type __test(...); 00797 }; 00798 00799 template<typename _Tp> 00800 struct __is_destructible_impl 00801 : public __do_is_destructible_impl 00802 { 00803 typedef decltype(__test<_Tp>(0)) type; 00804 }; 00805 00806 template<typename _Tp, 00807 bool = __or_<is_void<_Tp>, 00808 __is_array_unknown_bounds<_Tp>, 00809 is_function<_Tp>>::value, 00810 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> 00811 struct __is_destructible_safe; 00812 00813 template<typename _Tp> 00814 struct __is_destructible_safe<_Tp, false, false> 00815 : public __is_destructible_impl<typename 00816 remove_all_extents<_Tp>::type>::type 00817 { }; 00818 00819 template<typename _Tp> 00820 struct __is_destructible_safe<_Tp, true, false> 00821 : public false_type { }; 00822 00823 template<typename _Tp> 00824 struct __is_destructible_safe<_Tp, false, true> 00825 : public true_type { }; 00826 00827 /// is_destructible 00828 template<typename _Tp> 00829 struct is_destructible 00830 : public __is_destructible_safe<_Tp>::type 00831 { }; 00832 00833 // is_nothrow_destructible requires that is_destructible is 00834 // satisfied as well. We realize that by mimicing the 00835 // implementation of is_destructible but refer to noexcept(expr) 00836 // instead of decltype(expr). 00837 struct __do_is_nt_destructible_impl 00838 { 00839 template<typename _Tp> 00840 static __bool_constant<noexcept(declval<_Tp&>().~_Tp())> 00841 __test(int); 00842 00843 template<typename> 00844 static false_type __test(...); 00845 }; 00846 00847 template<typename _Tp> 00848 struct __is_nt_destructible_impl 00849 : public __do_is_nt_destructible_impl 00850 { 00851 typedef decltype(__test<_Tp>(0)) type; 00852 }; 00853 00854 template<typename _Tp, 00855 bool = __or_<is_void<_Tp>, 00856 __is_array_unknown_bounds<_Tp>, 00857 is_function<_Tp>>::value, 00858 bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> 00859 struct __is_nt_destructible_safe; 00860 00861 template<typename _Tp> 00862 struct __is_nt_destructible_safe<_Tp, false, false> 00863 : public __is_nt_destructible_impl<typename 00864 remove_all_extents<_Tp>::type>::type 00865 { }; 00866 00867 template<typename _Tp> 00868 struct __is_nt_destructible_safe<_Tp, true, false> 00869 : public false_type { }; 00870 00871 template<typename _Tp> 00872 struct __is_nt_destructible_safe<_Tp, false, true> 00873 : public true_type { }; 00874 00875 /// is_nothrow_destructible 00876 template<typename _Tp> 00877 struct is_nothrow_destructible 00878 : public __is_nt_destructible_safe<_Tp>::type 00879 { }; 00880 00881 /// is_constructible 00882 template<typename _Tp, typename... _Args> 00883 struct is_constructible 00884 : public __bool_constant<__is_constructible(_Tp, _Args...)> 00885 { }; 00886 00887 /// is_default_constructible 00888 template<typename _Tp> 00889 struct is_default_constructible 00890 : public is_constructible<_Tp>::type 00891 { }; 00892 00893 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 00894 struct __is_copy_constructible_impl; 00895 00896 template<typename _Tp> 00897 struct __is_copy_constructible_impl<_Tp, false> 00898 : public false_type { }; 00899 00900 template<typename _Tp> 00901 struct __is_copy_constructible_impl<_Tp, true> 00902 : public is_constructible<_Tp, const _Tp&> 00903 { }; 00904 00905 /// is_copy_constructible 00906 template<typename _Tp> 00907 struct is_copy_constructible 00908 : public __is_copy_constructible_impl<_Tp> 00909 { }; 00910 00911 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 00912 struct __is_move_constructible_impl; 00913 00914 template<typename _Tp> 00915 struct __is_move_constructible_impl<_Tp, false> 00916 : public false_type { }; 00917 00918 template<typename _Tp> 00919 struct __is_move_constructible_impl<_Tp, true> 00920 : public is_constructible<_Tp, _Tp&&> 00921 { }; 00922 00923 /// is_move_constructible 00924 template<typename _Tp> 00925 struct is_move_constructible 00926 : public __is_move_constructible_impl<_Tp> 00927 { }; 00928 00929 template<typename _Tp> 00930 struct __is_nt_default_constructible_atom 00931 : public integral_constant<bool, noexcept(_Tp())> 00932 { }; 00933 00934 template<typename _Tp, bool = is_array<_Tp>::value> 00935 struct __is_nt_default_constructible_impl; 00936 00937 template<typename _Tp> 00938 struct __is_nt_default_constructible_impl<_Tp, true> 00939 : public __and_<__is_array_known_bounds<_Tp>, 00940 __is_nt_default_constructible_atom<typename 00941 remove_all_extents<_Tp>::type>> 00942 { }; 00943 00944 template<typename _Tp> 00945 struct __is_nt_default_constructible_impl<_Tp, false> 00946 : public __is_nt_default_constructible_atom<_Tp> 00947 { }; 00948 00949 /// is_nothrow_default_constructible 00950 template<typename _Tp> 00951 struct is_nothrow_default_constructible 00952 : public __and_<is_default_constructible<_Tp>, 00953 __is_nt_default_constructible_impl<_Tp>> 00954 { }; 00955 00956 template<typename _Tp, typename... _Args> 00957 struct __is_nt_constructible_impl 00958 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 00959 { }; 00960 00961 template<typename _Tp, typename _Arg> 00962 struct __is_nt_constructible_impl<_Tp, _Arg> 00963 : public integral_constant<bool, 00964 noexcept(static_cast<_Tp>(declval<_Arg>()))> 00965 { }; 00966 00967 template<typename _Tp> 00968 struct __is_nt_constructible_impl<_Tp> 00969 : public is_nothrow_default_constructible<_Tp> 00970 { }; 00971 00972 /// is_nothrow_constructible 00973 template<typename _Tp, typename... _Args> 00974 struct is_nothrow_constructible 00975 : public __and_<is_constructible<_Tp, _Args...>, 00976 __is_nt_constructible_impl<_Tp, _Args...>> 00977 { }; 00978 00979 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 00980 struct __is_nothrow_copy_constructible_impl; 00981 00982 template<typename _Tp> 00983 struct __is_nothrow_copy_constructible_impl<_Tp, false> 00984 : public false_type { }; 00985 00986 template<typename _Tp> 00987 struct __is_nothrow_copy_constructible_impl<_Tp, true> 00988 : public is_nothrow_constructible<_Tp, const _Tp&> 00989 { }; 00990 00991 /// is_nothrow_copy_constructible 00992 template<typename _Tp> 00993 struct is_nothrow_copy_constructible 00994 : public __is_nothrow_copy_constructible_impl<_Tp> 00995 { }; 00996 00997 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 00998 struct __is_nothrow_move_constructible_impl; 00999 01000 template<typename _Tp> 01001 struct __is_nothrow_move_constructible_impl<_Tp, false> 01002 : public false_type { }; 01003 01004 template<typename _Tp> 01005 struct __is_nothrow_move_constructible_impl<_Tp, true> 01006 : public is_nothrow_constructible<_Tp, _Tp&&> 01007 { }; 01008 01009 /// is_nothrow_move_constructible 01010 template<typename _Tp> 01011 struct is_nothrow_move_constructible 01012 : public __is_nothrow_move_constructible_impl<_Tp> 01013 { }; 01014 01015 /// is_assignable 01016 template<typename _Tp, typename _Up> 01017 struct is_assignable 01018 : public __bool_constant<__is_assignable(_Tp, _Up)> 01019 { }; 01020 01021 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01022 struct __is_copy_assignable_impl; 01023 01024 template<typename _Tp> 01025 struct __is_copy_assignable_impl<_Tp, false> 01026 : public false_type { }; 01027 01028 template<typename _Tp> 01029 struct __is_copy_assignable_impl<_Tp, true> 01030 : public is_assignable<_Tp&, const _Tp&> 01031 { }; 01032 01033 /// is_copy_assignable 01034 template<typename _Tp> 01035 struct is_copy_assignable 01036 : public __is_copy_assignable_impl<_Tp> 01037 { }; 01038 01039 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01040 struct __is_move_assignable_impl; 01041 01042 template<typename _Tp> 01043 struct __is_move_assignable_impl<_Tp, false> 01044 : public false_type { }; 01045 01046 template<typename _Tp> 01047 struct __is_move_assignable_impl<_Tp, true> 01048 : public is_assignable<_Tp&, _Tp&&> 01049 { }; 01050 01051 /// is_move_assignable 01052 template<typename _Tp> 01053 struct is_move_assignable 01054 : public __is_move_assignable_impl<_Tp> 01055 { }; 01056 01057 template<typename _Tp, typename _Up> 01058 struct __is_nt_assignable_impl 01059 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())> 01060 { }; 01061 01062 /// is_nothrow_assignable 01063 template<typename _Tp, typename _Up> 01064 struct is_nothrow_assignable 01065 : public __and_<is_assignable<_Tp, _Up>, 01066 __is_nt_assignable_impl<_Tp, _Up>> 01067 { }; 01068 01069 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01070 struct __is_nt_copy_assignable_impl; 01071 01072 template<typename _Tp> 01073 struct __is_nt_copy_assignable_impl<_Tp, false> 01074 : public false_type { }; 01075 01076 template<typename _Tp> 01077 struct __is_nt_copy_assignable_impl<_Tp, true> 01078 : public is_nothrow_assignable<_Tp&, const _Tp&> 01079 { }; 01080 01081 /// is_nothrow_copy_assignable 01082 template<typename _Tp> 01083 struct is_nothrow_copy_assignable 01084 : public __is_nt_copy_assignable_impl<_Tp> 01085 { }; 01086 01087 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01088 struct __is_nt_move_assignable_impl; 01089 01090 template<typename _Tp> 01091 struct __is_nt_move_assignable_impl<_Tp, false> 01092 : public false_type { }; 01093 01094 template<typename _Tp> 01095 struct __is_nt_move_assignable_impl<_Tp, true> 01096 : public is_nothrow_assignable<_Tp&, _Tp&&> 01097 { }; 01098 01099 /// is_nothrow_move_assignable 01100 template<typename _Tp> 01101 struct is_nothrow_move_assignable 01102 : public __is_nt_move_assignable_impl<_Tp> 01103 { }; 01104 01105 /// is_trivially_constructible 01106 template<typename _Tp, typename... _Args> 01107 struct is_trivially_constructible 01108 : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> 01109 { }; 01110 01111 /// is_trivially_default_constructible 01112 template<typename _Tp> 01113 struct is_trivially_default_constructible 01114 : public is_trivially_constructible<_Tp>::type 01115 { }; 01116 01117 struct __do_is_implicitly_default_constructible_impl 01118 { 01119 template <typename _Tp> 01120 static void __helper(const _Tp&); 01121 01122 template <typename _Tp> 01123 static true_type __test(const _Tp&, 01124 decltype(__helper<const _Tp&>({}))* = 0); 01125 01126 static false_type __test(...); 01127 }; 01128 01129 template<typename _Tp> 01130 struct __is_implicitly_default_constructible_impl 01131 : public __do_is_implicitly_default_constructible_impl 01132 { 01133 typedef decltype(__test(declval<_Tp>())) type; 01134 }; 01135 01136 template<typename _Tp> 01137 struct __is_implicitly_default_constructible_safe 01138 : public __is_implicitly_default_constructible_impl<_Tp>::type 01139 { }; 01140 01141 template <typename _Tp> 01142 struct __is_implicitly_default_constructible 01143 : public __and_<is_default_constructible<_Tp>, 01144 __is_implicitly_default_constructible_safe<_Tp>> 01145 { }; 01146 01147 /// is_trivially_copy_constructible 01148 01149 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01150 struct __is_trivially_copy_constructible_impl; 01151 01152 template<typename _Tp> 01153 struct __is_trivially_copy_constructible_impl<_Tp, false> 01154 : public false_type { }; 01155 01156 template<typename _Tp> 01157 struct __is_trivially_copy_constructible_impl<_Tp, true> 01158 : public __and_<is_copy_constructible<_Tp>, 01159 integral_constant<bool, 01160 __is_trivially_constructible(_Tp, const _Tp&)>> 01161 { }; 01162 01163 template<typename _Tp> 01164 struct is_trivially_copy_constructible 01165 : public __is_trivially_copy_constructible_impl<_Tp> 01166 { }; 01167 01168 /// is_trivially_move_constructible 01169 01170 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01171 struct __is_trivially_move_constructible_impl; 01172 01173 template<typename _Tp> 01174 struct __is_trivially_move_constructible_impl<_Tp, false> 01175 : public false_type { }; 01176 01177 template<typename _Tp> 01178 struct __is_trivially_move_constructible_impl<_Tp, true> 01179 : public __and_<is_move_constructible<_Tp>, 01180 integral_constant<bool, 01181 __is_trivially_constructible(_Tp, _Tp&&)>> 01182 { }; 01183 01184 template<typename _Tp> 01185 struct is_trivially_move_constructible 01186 : public __is_trivially_move_constructible_impl<_Tp> 01187 { }; 01188 01189 /// is_trivially_assignable 01190 template<typename _Tp, typename _Up> 01191 struct is_trivially_assignable 01192 : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> 01193 { }; 01194 01195 /// is_trivially_copy_assignable 01196 01197 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01198 struct __is_trivially_copy_assignable_impl; 01199 01200 template<typename _Tp> 01201 struct __is_trivially_copy_assignable_impl<_Tp, false> 01202 : public false_type { }; 01203 01204 template<typename _Tp> 01205 struct __is_trivially_copy_assignable_impl<_Tp, true> 01206 : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> 01207 { }; 01208 01209 template<typename _Tp> 01210 struct is_trivially_copy_assignable 01211 : public __is_trivially_copy_assignable_impl<_Tp> 01212 { }; 01213 01214 /// is_trivially_move_assignable 01215 01216 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01217 struct __is_trivially_move_assignable_impl; 01218 01219 template<typename _Tp> 01220 struct __is_trivially_move_assignable_impl<_Tp, false> 01221 : public false_type { }; 01222 01223 template<typename _Tp> 01224 struct __is_trivially_move_assignable_impl<_Tp, true> 01225 : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> 01226 { }; 01227 01228 template<typename _Tp> 01229 struct is_trivially_move_assignable 01230 : public __is_trivially_move_assignable_impl<_Tp> 01231 { }; 01232 01233 /// is_trivially_destructible 01234 template<typename _Tp> 01235 struct is_trivially_destructible 01236 : public __and_<is_destructible<_Tp>, 01237 __bool_constant<__has_trivial_destructor(_Tp)>> 01238 { }; 01239 01240 01241 /// has_virtual_destructor 01242 template<typename _Tp> 01243 struct has_virtual_destructor 01244 : public integral_constant<bool, __has_virtual_destructor(_Tp)> 01245 { }; 01246 01247 01248 // type property queries. 01249 01250 /// alignment_of 01251 template<typename _Tp> 01252 struct alignment_of 01253 : public integral_constant<std::size_t, alignof(_Tp)> { }; 01254 01255 /// rank 01256 template<typename> 01257 struct rank 01258 : public integral_constant<std::size_t, 0> { }; 01259 01260 template<typename _Tp, std::size_t _Size> 01261 struct rank<_Tp[_Size]> 01262 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; 01263 01264 template<typename _Tp> 01265 struct rank<_Tp[]> 01266 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; 01267 01268 /// extent 01269 template<typename, unsigned _Uint> 01270 struct extent 01271 : public integral_constant<std::size_t, 0> { }; 01272 01273 template<typename _Tp, unsigned _Uint, std::size_t _Size> 01274 struct extent<_Tp[_Size], _Uint> 01275 : public integral_constant<std::size_t, 01276 _Uint == 0 ? _Size : extent<_Tp, 01277 _Uint - 1>::value> 01278 { }; 01279 01280 template<typename _Tp, unsigned _Uint> 01281 struct extent<_Tp[], _Uint> 01282 : public integral_constant<std::size_t, 01283 _Uint == 0 ? 0 : extent<_Tp, 01284 _Uint - 1>::value> 01285 { }; 01286 01287 01288 // Type relations. 01289 01290 /// is_same 01291 template<typename, typename> 01292 struct is_same 01293 : public false_type { }; 01294 01295 template<typename _Tp> 01296 struct is_same<_Tp, _Tp> 01297 : public true_type { }; 01298 01299 /// is_base_of 01300 template<typename _Base, typename _Derived> 01301 struct is_base_of 01302 : public integral_constant<bool, __is_base_of(_Base, _Derived)> 01303 { }; 01304 01305 template<typename _From, typename _To, 01306 bool = __or_<is_void<_From>, is_function<_To>, 01307 is_array<_To>>::value> 01308 struct __is_convertible_helper 01309 { 01310 typedef typename is_void<_To>::type type; 01311 }; 01312 01313 template<typename _From, typename _To> 01314 class __is_convertible_helper<_From, _To, false> 01315 { 01316 template<typename _To1> 01317 static void __test_aux(_To1) noexcept; 01318 01319 template<typename _From1, typename _To1, 01320 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> 01321 static true_type 01322 __test(int); 01323 01324 template<typename, typename> 01325 static false_type 01326 __test(...); 01327 01328 public: 01329 typedef decltype(__test<_From, _To>(0)) type; 01330 }; 01331 01332 01333 /// is_convertible 01334 template<typename _From, typename _To> 01335 struct is_convertible 01336 : public __is_convertible_helper<_From, _To>::type 01337 { }; 01338 01339 #if __cplusplus > 201703L 01340 template<typename _From, typename _To, 01341 bool = __or_<is_void<_From>, is_function<_To>, 01342 is_array<_To>>::value> 01343 struct __is_nt_convertible_helper 01344 : is_void<_To> 01345 { }; 01346 01347 template<typename _From, typename _To> 01348 class __is_nt_convertible_helper<_From, _To, false> 01349 { 01350 template<typename _To1> 01351 static void __test_aux(_To1) noexcept; 01352 01353 template<typename _From1, typename _To1> 01354 static bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))> 01355 __test(int); 01356 01357 template<typename, typename> 01358 static false_type 01359 __test(...); 01360 01361 public: 01362 using type = decltype(__test<_From, _To>(0)); 01363 }; 01364 01365 /// is_nothrow_convertible 01366 template<typename _From, typename _To> 01367 struct is_nothrow_convertible 01368 : public __is_nt_convertible_helper<_From, _To>::type 01369 { }; 01370 01371 /// is_nothrow_convertible_v 01372 template<typename _From, typename _To> 01373 inline constexpr bool is_nothrow_convertible_v 01374 = is_nothrow_convertible<_From, _To>::value; 01375 #endif // C++2a 01376 01377 // Const-volatile modifications. 01378 01379 /// remove_const 01380 template<typename _Tp> 01381 struct remove_const 01382 { typedef _Tp type; }; 01383 01384 template<typename _Tp> 01385 struct remove_const<_Tp const> 01386 { typedef _Tp type; }; 01387 01388 /// remove_volatile 01389 template<typename _Tp> 01390 struct remove_volatile 01391 { typedef _Tp type; }; 01392 01393 template<typename _Tp> 01394 struct remove_volatile<_Tp volatile> 01395 { typedef _Tp type; }; 01396 01397 /// remove_cv 01398 template<typename _Tp> 01399 struct remove_cv 01400 { 01401 typedef typename 01402 remove_const<typename remove_volatile<_Tp>::type>::type type; 01403 }; 01404 01405 /// add_const 01406 template<typename _Tp> 01407 struct add_const 01408 { typedef _Tp const type; }; 01409 01410 /// add_volatile 01411 template<typename _Tp> 01412 struct add_volatile 01413 { typedef _Tp volatile type; }; 01414 01415 /// add_cv 01416 template<typename _Tp> 01417 struct add_cv 01418 { 01419 typedef typename 01420 add_const<typename add_volatile<_Tp>::type>::type type; 01421 }; 01422 01423 #if __cplusplus > 201103L 01424 01425 #define __cpp_lib_transformation_trait_aliases 201304 01426 01427 /// Alias template for remove_const 01428 template<typename _Tp> 01429 using remove_const_t = typename remove_const<_Tp>::type; 01430 01431 /// Alias template for remove_volatile 01432 template<typename _Tp> 01433 using remove_volatile_t = typename remove_volatile<_Tp>::type; 01434 01435 /// Alias template for remove_cv 01436 template<typename _Tp> 01437 using remove_cv_t = typename remove_cv<_Tp>::type; 01438 01439 /// Alias template for add_const 01440 template<typename _Tp> 01441 using add_const_t = typename add_const<_Tp>::type; 01442 01443 /// Alias template for add_volatile 01444 template<typename _Tp> 01445 using add_volatile_t = typename add_volatile<_Tp>::type; 01446 01447 /// Alias template for add_cv 01448 template<typename _Tp> 01449 using add_cv_t = typename add_cv<_Tp>::type; 01450 #endif 01451 01452 // Reference transformations. 01453 01454 /// remove_reference 01455 template<typename _Tp> 01456 struct remove_reference 01457 { typedef _Tp type; }; 01458 01459 template<typename _Tp> 01460 struct remove_reference<_Tp&> 01461 { typedef _Tp type; }; 01462 01463 template<typename _Tp> 01464 struct remove_reference<_Tp&&> 01465 { typedef _Tp type; }; 01466 01467 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01468 struct __add_lvalue_reference_helper 01469 { typedef _Tp type; }; 01470 01471 template<typename _Tp> 01472 struct __add_lvalue_reference_helper<_Tp, true> 01473 { typedef _Tp& type; }; 01474 01475 /// add_lvalue_reference 01476 template<typename _Tp> 01477 struct add_lvalue_reference 01478 : public __add_lvalue_reference_helper<_Tp> 01479 { }; 01480 01481 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01482 struct __add_rvalue_reference_helper 01483 { typedef _Tp type; }; 01484 01485 template<typename _Tp> 01486 struct __add_rvalue_reference_helper<_Tp, true> 01487 { typedef _Tp&& type; }; 01488 01489 /// add_rvalue_reference 01490 template<typename _Tp> 01491 struct add_rvalue_reference 01492 : public __add_rvalue_reference_helper<_Tp> 01493 { }; 01494 01495 #if __cplusplus > 201103L 01496 /// Alias template for remove_reference 01497 template<typename _Tp> 01498 using remove_reference_t = typename remove_reference<_Tp>::type; 01499 01500 /// Alias template for add_lvalue_reference 01501 template<typename _Tp> 01502 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; 01503 01504 /// Alias template for add_rvalue_reference 01505 template<typename _Tp> 01506 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; 01507 #endif 01508 01509 // Sign modifications. 01510 01511 // Utility for constructing identically cv-qualified types. 01512 template<typename _Unqualified, bool _IsConst, bool _IsVol> 01513 struct __cv_selector; 01514 01515 template<typename _Unqualified> 01516 struct __cv_selector<_Unqualified, false, false> 01517 { typedef _Unqualified __type; }; 01518 01519 template<typename _Unqualified> 01520 struct __cv_selector<_Unqualified, false, true> 01521 { typedef volatile _Unqualified __type; }; 01522 01523 template<typename _Unqualified> 01524 struct __cv_selector<_Unqualified, true, false> 01525 { typedef const _Unqualified __type; }; 01526 01527 template<typename _Unqualified> 01528 struct __cv_selector<_Unqualified, true, true> 01529 { typedef const volatile _Unqualified __type; }; 01530 01531 template<typename _Qualified, typename _Unqualified, 01532 bool _IsConst = is_const<_Qualified>::value, 01533 bool _IsVol = is_volatile<_Qualified>::value> 01534 class __match_cv_qualifiers 01535 { 01536 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; 01537 01538 public: 01539 typedef typename __match::__type __type; 01540 }; 01541 01542 // Utility for finding the unsigned versions of signed integral types. 01543 template<typename _Tp> 01544 struct __make_unsigned 01545 { typedef _Tp __type; }; 01546 01547 template<> 01548 struct __make_unsigned<char> 01549 { typedef unsigned char __type; }; 01550 01551 template<> 01552 struct __make_unsigned<signed char> 01553 { typedef unsigned char __type; }; 01554 01555 template<> 01556 struct __make_unsigned<short> 01557 { typedef unsigned short __type; }; 01558 01559 template<> 01560 struct __make_unsigned<int> 01561 { typedef unsigned int __type; }; 01562 01563 template<> 01564 struct __make_unsigned<long> 01565 { typedef unsigned long __type; }; 01566 01567 template<> 01568 struct __make_unsigned<long long> 01569 { typedef unsigned long long __type; }; 01570 01571 #if defined(__GLIBCXX_TYPE_INT_N_0) 01572 template<> 01573 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> 01574 { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; 01575 #endif 01576 #if defined(__GLIBCXX_TYPE_INT_N_1) 01577 template<> 01578 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> 01579 { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; 01580 #endif 01581 #if defined(__GLIBCXX_TYPE_INT_N_2) 01582 template<> 01583 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> 01584 { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; 01585 #endif 01586 #if defined(__GLIBCXX_TYPE_INT_N_3) 01587 template<> 01588 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> 01589 { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; 01590 #endif 01591 01592 // Select between integral and enum: not possible to be both. 01593 template<typename _Tp, 01594 bool _IsInt = is_integral<_Tp>::value, 01595 bool _IsEnum = is_enum<_Tp>::value> 01596 class __make_unsigned_selector; 01597 01598 template<typename _Tp> 01599 class __make_unsigned_selector<_Tp, true, false> 01600 { 01601 using __unsigned_type 01602 = typename __make_unsigned<typename remove_cv<_Tp>::type>::__type; 01603 01604 public: 01605 using __type 01606 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; 01607 }; 01608 01609 class __make_unsigned_selector_base 01610 { 01611 protected: 01612 template<typename...> struct _List { }; 01613 01614 template<typename _Tp, typename... _Up> 01615 struct _List<_Tp, _Up...> : _List<_Up...> 01616 { static constexpr size_t __size = sizeof(_Tp); }; 01617 01618 template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> 01619 struct __select; 01620 01621 template<size_t _Sz, typename _Uint, typename... _UInts> 01622 struct __select<_Sz, _List<_Uint, _UInts...>, true> 01623 { using __type = _Uint; }; 01624 01625 template<size_t _Sz, typename _Uint, typename... _UInts> 01626 struct __select<_Sz, _List<_Uint, _UInts...>, false> 01627 : __select<_Sz, _List<_UInts...>> 01628 { }; 01629 }; 01630 01631 // Choose unsigned integer type with the smallest rank and same size as _Tp 01632 template<typename _Tp> 01633 class __make_unsigned_selector<_Tp, false, true> 01634 : __make_unsigned_selector_base 01635 { 01636 // With -fshort-enums, an enum may be as small as a char. 01637 using _UInts = _List<unsigned char, unsigned short, unsigned int, 01638 unsigned long, unsigned long long>; 01639 01640 using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; 01641 01642 public: 01643 using __type 01644 = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; 01645 }; 01646 01647 // wchar_t, char8_t, char16_t and char32_t are integral types but are 01648 // neither signed integer types nor unsigned integer types, so must be 01649 // transformed to the unsigned integer type with the smallest rank. 01650 // Use the partial specialization for enumeration types to do that. 01651 #if defined(_GLIBCXX_USE_WCHAR_T) 01652 template<> 01653 struct __make_unsigned<wchar_t> 01654 { 01655 using __type 01656 = typename __make_unsigned_selector<wchar_t, false, true>::__type; 01657 }; 01658 #endif 01659 01660 #ifdef _GLIBCXX_USE_CHAR8_T 01661 template<> 01662 struct __make_unsigned<char8_t> 01663 { 01664 using __type 01665 = typename __make_unsigned_selector<char8_t, false, true>::__type; 01666 }; 01667 #endif 01668 01669 template<> 01670 struct __make_unsigned<char16_t> 01671 { 01672 using __type 01673 = typename __make_unsigned_selector<char16_t, false, true>::__type; 01674 }; 01675 01676 template<> 01677 struct __make_unsigned<char32_t> 01678 { 01679 using __type 01680 = typename __make_unsigned_selector<char32_t, false, true>::__type; 01681 }; 01682 01683 // Given an integral/enum type, return the corresponding unsigned 01684 // integer type. 01685 // Primary template. 01686 /// make_unsigned 01687 template<typename _Tp> 01688 struct make_unsigned 01689 { typedef typename __make_unsigned_selector<_Tp>::__type type; }; 01690 01691 // Integral, but don't define. 01692 template<> 01693 struct make_unsigned<bool>; 01694 01695 01696 // Utility for finding the signed versions of unsigned integral types. 01697 template<typename _Tp> 01698 struct __make_signed 01699 { typedef _Tp __type; }; 01700 01701 template<> 01702 struct __make_signed<char> 01703 { typedef signed char __type; }; 01704 01705 template<> 01706 struct __make_signed<unsigned char> 01707 { typedef signed char __type; }; 01708 01709 template<> 01710 struct __make_signed<unsigned short> 01711 { typedef signed short __type; }; 01712 01713 template<> 01714 struct __make_signed<unsigned int> 01715 { typedef signed int __type; }; 01716 01717 template<> 01718 struct __make_signed<unsigned long> 01719 { typedef signed long __type; }; 01720 01721 template<> 01722 struct __make_signed<unsigned long long> 01723 { typedef signed long long __type; }; 01724 01725 #if defined(__GLIBCXX_TYPE_INT_N_0) 01726 template<> 01727 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> 01728 { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; 01729 #endif 01730 #if defined(__GLIBCXX_TYPE_INT_N_1) 01731 template<> 01732 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> 01733 { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; 01734 #endif 01735 #if defined(__GLIBCXX_TYPE_INT_N_2) 01736 template<> 01737 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> 01738 { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; 01739 #endif 01740 #if defined(__GLIBCXX_TYPE_INT_N_3) 01741 template<> 01742 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> 01743 { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; 01744 #endif 01745 01746 // Select between integral and enum: not possible to be both. 01747 template<typename _Tp, 01748 bool _IsInt = is_integral<_Tp>::value, 01749 bool _IsEnum = is_enum<_Tp>::value> 01750 class __make_signed_selector; 01751 01752 template<typename _Tp> 01753 class __make_signed_selector<_Tp, true, false> 01754 { 01755 using __signed_type 01756 = typename __make_signed<typename remove_cv<_Tp>::type>::__type; 01757 01758 public: 01759 using __type 01760 = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; 01761 }; 01762 01763 // Choose signed integer type with the smallest rank and same size as _Tp 01764 template<typename _Tp> 01765 class __make_signed_selector<_Tp, false, true> 01766 { 01767 typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; 01768 01769 public: 01770 typedef typename __make_signed_selector<__unsigned_type>::__type __type; 01771 }; 01772 01773 // wchar_t, char16_t and char32_t are integral types but are neither 01774 // signed integer types nor unsigned integer types, so must be 01775 // transformed to the signed integer type with the smallest rank. 01776 // Use the partial specialization for enumeration types to do that. 01777 #if defined(_GLIBCXX_USE_WCHAR_T) 01778 template<> 01779 struct __make_signed<wchar_t> 01780 { 01781 using __type 01782 = typename __make_signed_selector<wchar_t, false, true>::__type; 01783 }; 01784 #endif 01785 01786 #if defined(_GLIBCXX_USE_CHAR8_T) 01787 template<> 01788 struct __make_signed<char8_t> 01789 { 01790 using __type 01791 = typename __make_signed_selector<char8_t, false, true>::__type; 01792 }; 01793 #endif 01794 01795 template<> 01796 struct __make_signed<char16_t> 01797 { 01798 using __type 01799 = typename __make_signed_selector<char16_t, false, true>::__type; 01800 }; 01801 01802 template<> 01803 struct __make_signed<char32_t> 01804 { 01805 using __type 01806 = typename __make_signed_selector<char32_t, false, true>::__type; 01807 }; 01808 01809 // Given an integral/enum type, return the corresponding signed 01810 // integer type. 01811 // Primary template. 01812 /// make_signed 01813 template<typename _Tp> 01814 struct make_signed 01815 { typedef typename __make_signed_selector<_Tp>::__type type; }; 01816 01817 // Integral, but don't define. 01818 template<> 01819 struct make_signed<bool>; 01820 01821 #if __cplusplus > 201103L 01822 /// Alias template for make_signed 01823 template<typename _Tp> 01824 using make_signed_t = typename make_signed<_Tp>::type; 01825 01826 /// Alias template for make_unsigned 01827 template<typename _Tp> 01828 using make_unsigned_t = typename make_unsigned<_Tp>::type; 01829 #endif 01830 01831 // Array modifications. 01832 01833 /// remove_extent 01834 template<typename _Tp> 01835 struct remove_extent 01836 { typedef _Tp type; }; 01837 01838 template<typename _Tp, std::size_t _Size> 01839 struct remove_extent<_Tp[_Size]> 01840 { typedef _Tp type; }; 01841 01842 template<typename _Tp> 01843 struct remove_extent<_Tp[]> 01844 { typedef _Tp type; }; 01845 01846 /// remove_all_extents 01847 template<typename _Tp> 01848 struct remove_all_extents 01849 { typedef _Tp type; }; 01850 01851 template<typename _Tp, std::size_t _Size> 01852 struct remove_all_extents<_Tp[_Size]> 01853 { typedef typename remove_all_extents<_Tp>::type type; }; 01854 01855 template<typename _Tp> 01856 struct remove_all_extents<_Tp[]> 01857 { typedef typename remove_all_extents<_Tp>::type type; }; 01858 01859 #if __cplusplus > 201103L 01860 /// Alias template for remove_extent 01861 template<typename _Tp> 01862 using remove_extent_t = typename remove_extent<_Tp>::type; 01863 01864 /// Alias template for remove_all_extents 01865 template<typename _Tp> 01866 using remove_all_extents_t = typename remove_all_extents<_Tp>::type; 01867 #endif 01868 01869 // Pointer modifications. 01870 01871 template<typename _Tp, typename> 01872 struct __remove_pointer_helper 01873 { typedef _Tp type; }; 01874 01875 template<typename _Tp, typename _Up> 01876 struct __remove_pointer_helper<_Tp, _Up*> 01877 { typedef _Up type; }; 01878 01879 /// remove_pointer 01880 template<typename _Tp> 01881 struct remove_pointer 01882 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> 01883 { }; 01884 01885 /// add_pointer 01886 template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, 01887 is_void<_Tp>>::value> 01888 struct __add_pointer_helper 01889 { typedef _Tp type; }; 01890 01891 template<typename _Tp> 01892 struct __add_pointer_helper<_Tp, true> 01893 { typedef typename remove_reference<_Tp>::type* type; }; 01894 01895 template<typename _Tp> 01896 struct add_pointer 01897 : public __add_pointer_helper<_Tp> 01898 { }; 01899 01900 #if __cplusplus > 201103L 01901 /// Alias template for remove_pointer 01902 template<typename _Tp> 01903 using remove_pointer_t = typename remove_pointer<_Tp>::type; 01904 01905 /// Alias template for add_pointer 01906 template<typename _Tp> 01907 using add_pointer_t = typename add_pointer<_Tp>::type; 01908 #endif 01909 01910 template<std::size_t _Len> 01911 struct __aligned_storage_msa 01912 { 01913 union __type 01914 { 01915 unsigned char __data[_Len]; 01916 struct __attribute__((__aligned__)) { } __align; 01917 }; 01918 }; 01919 01920 /** 01921 * @brief Alignment type. 01922 * 01923 * The value of _Align is a default-alignment which shall be the 01924 * most stringent alignment requirement for any C++ object type 01925 * whose size is no greater than _Len (3.9). The member typedef 01926 * type shall be a POD type suitable for use as uninitialized 01927 * storage for any object whose size is at most _Len and whose 01928 * alignment is a divisor of _Align. 01929 */ 01930 template<std::size_t _Len, std::size_t _Align = 01931 __alignof__(typename __aligned_storage_msa<_Len>::__type)> 01932 struct aligned_storage 01933 { 01934 union type 01935 { 01936 unsigned char __data[_Len]; 01937 struct __attribute__((__aligned__((_Align)))) { } __align; 01938 }; 01939 }; 01940 01941 template <typename... _Types> 01942 struct __strictest_alignment 01943 { 01944 static const size_t _S_alignment = 0; 01945 static const size_t _S_size = 0; 01946 }; 01947 01948 template <typename _Tp, typename... _Types> 01949 struct __strictest_alignment<_Tp, _Types...> 01950 { 01951 static const size_t _S_alignment = 01952 alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment 01953 ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; 01954 static const size_t _S_size = 01955 sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size 01956 ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; 01957 }; 01958 01959 /** 01960 * @brief Provide aligned storage for types. 01961 * 01962 * [meta.trans.other] 01963 * 01964 * Provides aligned storage for any of the provided types of at 01965 * least size _Len. 01966 * 01967 * @see aligned_storage 01968 */ 01969 template <size_t _Len, typename... _Types> 01970 struct aligned_union 01971 { 01972 private: 01973 static_assert(sizeof...(_Types) != 0, "At least one type is required"); 01974 01975 using __strictest = __strictest_alignment<_Types...>; 01976 static const size_t _S_len = _Len > __strictest::_S_size 01977 ? _Len : __strictest::_S_size; 01978 public: 01979 /// The value of the strictest alignment of _Types. 01980 static const size_t alignment_value = __strictest::_S_alignment; 01981 /// The storage. 01982 typedef typename aligned_storage<_S_len, alignment_value>::type type; 01983 }; 01984 01985 template <size_t _Len, typename... _Types> 01986 const size_t aligned_union<_Len, _Types...>::alignment_value; 01987 01988 // Decay trait for arrays and functions, used for perfect forwarding 01989 // in make_pair, make_tuple, etc. 01990 template<typename _Up, 01991 bool _IsArray = is_array<_Up>::value, 01992 bool _IsFunction = is_function<_Up>::value> 01993 struct __decay_selector; 01994 01995 // NB: DR 705. 01996 template<typename _Up> 01997 struct __decay_selector<_Up, false, false> 01998 { typedef typename remove_cv<_Up>::type __type; }; 01999 02000 template<typename _Up> 02001 struct __decay_selector<_Up, true, false> 02002 { typedef typename remove_extent<_Up>::type* __type; }; 02003 02004 template<typename _Up> 02005 struct __decay_selector<_Up, false, true> 02006 { typedef typename add_pointer<_Up>::type __type; }; 02007 02008 /// decay 02009 template<typename _Tp> 02010 class decay 02011 { 02012 typedef typename remove_reference<_Tp>::type __remove_type; 02013 02014 public: 02015 typedef typename __decay_selector<__remove_type>::__type type; 02016 }; 02017 02018 template<typename _Tp> 02019 class reference_wrapper; 02020 02021 // Helper which adds a reference to a type when given a reference_wrapper 02022 template<typename _Tp> 02023 struct __strip_reference_wrapper 02024 { 02025 typedef _Tp __type; 02026 }; 02027 02028 template<typename _Tp> 02029 struct __strip_reference_wrapper<reference_wrapper<_Tp> > 02030 { 02031 typedef _Tp& __type; 02032 }; 02033 02034 template<typename _Tp> 02035 struct __decay_and_strip 02036 { 02037 typedef typename __strip_reference_wrapper< 02038 typename decay<_Tp>::type>::__type __type; 02039 }; 02040 02041 02042 // Primary template. 02043 /// Define a member typedef @c type only if a boolean constant is true. 02044 template<bool, typename _Tp = void> 02045 struct enable_if 02046 { }; 02047 02048 // Partial specialization for true. 02049 template<typename _Tp> 02050 struct enable_if<true, _Tp> 02051 { typedef _Tp type; }; 02052 02053 template<typename... _Cond> 02054 using _Require = typename enable_if<__and_<_Cond...>::value>::type; 02055 02056 // Primary template. 02057 /// Define a member typedef @c type to one of two argument types. 02058 template<bool _Cond, typename _Iftrue, typename _Iffalse> 02059 struct conditional 02060 { typedef _Iftrue type; }; 02061 02062 // Partial specialization for false. 02063 template<typename _Iftrue, typename _Iffalse> 02064 struct conditional<false, _Iftrue, _Iffalse> 02065 { typedef _Iffalse type; }; 02066 02067 /// common_type 02068 template<typename... _Tp> 02069 struct common_type; 02070 02071 // Sfinae-friendly common_type implementation: 02072 02073 struct __do_common_type_impl 02074 { 02075 template<typename _Tp, typename _Up> 02076 static __success_type<typename decay<decltype 02077 (true ? std::declval<_Tp>() 02078 : std::declval<_Up>())>::type> _S_test(int); 02079 02080 template<typename, typename> 02081 static __failure_type _S_test(...); 02082 }; 02083 02084 template<typename _Tp, typename _Up> 02085 struct __common_type_impl 02086 : private __do_common_type_impl 02087 { 02088 typedef decltype(_S_test<_Tp, _Up>(0)) type; 02089 }; 02090 02091 struct __do_member_type_wrapper 02092 { 02093 template<typename _Tp> 02094 static __success_type<typename _Tp::type> _S_test(int); 02095 02096 template<typename> 02097 static __failure_type _S_test(...); 02098 }; 02099 02100 template<typename _Tp> 02101 struct __member_type_wrapper 02102 : private __do_member_type_wrapper 02103 { 02104 typedef decltype(_S_test<_Tp>(0)) type; 02105 }; 02106 02107 template<typename _CTp, typename... _Args> 02108 struct __expanded_common_type_wrapper 02109 { 02110 typedef common_type<typename _CTp::type, _Args...> type; 02111 }; 02112 02113 template<typename... _Args> 02114 struct __expanded_common_type_wrapper<__failure_type, _Args...> 02115 { typedef __failure_type type; }; 02116 02117 template<> 02118 struct common_type<> 02119 { }; 02120 02121 template<typename _Tp> 02122 struct common_type<_Tp> 02123 : common_type<_Tp, _Tp> 02124 { }; 02125 02126 template<typename _Tp, typename _Up> 02127 struct common_type<_Tp, _Up> 02128 : public __common_type_impl<_Tp, _Up>::type 02129 { }; 02130 02131 template<typename _Tp, typename _Up, typename... _Vp> 02132 struct common_type<_Tp, _Up, _Vp...> 02133 : public __expanded_common_type_wrapper<typename __member_type_wrapper< 02134 common_type<_Tp, _Up>>::type, _Vp...>::type 02135 { }; 02136 02137 template<typename _Tp, bool = is_enum<_Tp>::value> 02138 struct __underlying_type_impl 02139 { 02140 using type = __underlying_type(_Tp); 02141 }; 02142 02143 template<typename _Tp> 02144 struct __underlying_type_impl<_Tp, false> 02145 { }; 02146 02147 /// The underlying type of an enum. 02148 template<typename _Tp> 02149 struct underlying_type 02150 : public __underlying_type_impl<_Tp> 02151 { }; 02152 02153 template<typename _Tp> 02154 struct __declval_protector 02155 { 02156 static const bool __stop = false; 02157 }; 02158 02159 template<typename _Tp> 02160 auto declval() noexcept -> decltype(__declval<_Tp>(0)) 02161 { 02162 static_assert(__declval_protector<_Tp>::__stop, 02163 "declval() must not be used!"); 02164 return __declval<_Tp>(0); 02165 } 02166 02167 // __remove_cvref_t (std::remove_cvref_t for C++11). 02168 template<typename _Tp> 02169 using __remove_cvref_t 02170 = typename remove_cv<typename remove_reference<_Tp>::type>::type; 02171 02172 /// result_of 02173 template<typename _Signature> 02174 class result_of; 02175 02176 // Sfinae-friendly result_of implementation: 02177 02178 #define __cpp_lib_result_of_sfinae 201210 02179 02180 struct __invoke_memfun_ref { }; 02181 struct __invoke_memfun_deref { }; 02182 struct __invoke_memobj_ref { }; 02183 struct __invoke_memobj_deref { }; 02184 struct __invoke_other { }; 02185 02186 // Associate a tag type with a specialization of __success_type. 02187 template<typename _Tp, typename _Tag> 02188 struct __result_of_success : __success_type<_Tp> 02189 { using __invoke_type = _Tag; }; 02190 02191 // [func.require] paragraph 1 bullet 1: 02192 struct __result_of_memfun_ref_impl 02193 { 02194 template<typename _Fp, typename _Tp1, typename... _Args> 02195 static __result_of_success<decltype( 02196 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) 02197 ), __invoke_memfun_ref> _S_test(int); 02198 02199 template<typename...> 02200 static __failure_type _S_test(...); 02201 }; 02202 02203 template<typename _MemPtr, typename _Arg, typename... _Args> 02204 struct __result_of_memfun_ref 02205 : private __result_of_memfun_ref_impl 02206 { 02207 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; 02208 }; 02209 02210 // [func.require] paragraph 1 bullet 2: 02211 struct __result_of_memfun_deref_impl 02212 { 02213 template<typename _Fp, typename _Tp1, typename... _Args> 02214 static __result_of_success<decltype( 02215 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) 02216 ), __invoke_memfun_deref> _S_test(int); 02217 02218 template<typename...> 02219 static __failure_type _S_test(...); 02220 }; 02221 02222 template<typename _MemPtr, typename _Arg, typename... _Args> 02223 struct __result_of_memfun_deref 02224 : private __result_of_memfun_deref_impl 02225 { 02226 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; 02227 }; 02228 02229 // [func.require] paragraph 1 bullet 3: 02230 struct __result_of_memobj_ref_impl 02231 { 02232 template<typename _Fp, typename _Tp1> 02233 static __result_of_success<decltype( 02234 std::declval<_Tp1>().*std::declval<_Fp>() 02235 ), __invoke_memobj_ref> _S_test(int); 02236 02237 template<typename, typename> 02238 static __failure_type _S_test(...); 02239 }; 02240 02241 template<typename _MemPtr, typename _Arg> 02242 struct __result_of_memobj_ref 02243 : private __result_of_memobj_ref_impl 02244 { 02245 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; 02246 }; 02247 02248 // [func.require] paragraph 1 bullet 4: 02249 struct __result_of_memobj_deref_impl 02250 { 02251 template<typename _Fp, typename _Tp1> 02252 static __result_of_success<decltype( 02253 (*std::declval<_Tp1>()).*std::declval<_Fp>() 02254 ), __invoke_memobj_deref> _S_test(int); 02255 02256 template<typename, typename> 02257 static __failure_type _S_test(...); 02258 }; 02259 02260 template<typename _MemPtr, typename _Arg> 02261 struct __result_of_memobj_deref 02262 : private __result_of_memobj_deref_impl 02263 { 02264 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; 02265 }; 02266 02267 template<typename _MemPtr, typename _Arg> 02268 struct __result_of_memobj; 02269 02270 template<typename _Res, typename _Class, typename _Arg> 02271 struct __result_of_memobj<_Res _Class::*, _Arg> 02272 { 02273 typedef __remove_cvref_t<_Arg> _Argval; 02274 typedef _Res _Class::* _MemPtr; 02275 typedef typename conditional<__or_<is_same<_Argval, _Class>, 02276 is_base_of<_Class, _Argval>>::value, 02277 __result_of_memobj_ref<_MemPtr, _Arg>, 02278 __result_of_memobj_deref<_MemPtr, _Arg> 02279 >::type::type type; 02280 }; 02281 02282 template<typename _MemPtr, typename _Arg, typename... _Args> 02283 struct __result_of_memfun; 02284 02285 template<typename _Res, typename _Class, typename _Arg, typename... _Args> 02286 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> 02287 { 02288 typedef typename remove_reference<_Arg>::type _Argval; 02289 typedef _Res _Class::* _MemPtr; 02290 typedef typename conditional<is_base_of<_Class, _Argval>::value, 02291 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, 02292 __result_of_memfun_deref<_MemPtr, _Arg, _Args...> 02293 >::type::type type; 02294 }; 02295 02296 // _GLIBCXX_RESOLVE_LIB_DEFECTS 02297 // 2219. INVOKE-ing a pointer to member with a reference_wrapper 02298 // as the object expression 02299 02300 // Used by result_of, invoke etc. to unwrap a reference_wrapper. 02301 template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>> 02302 struct __inv_unwrap 02303 { 02304 using type = _Tp; 02305 }; 02306 02307 template<typename _Tp, typename _Up> 02308 struct __inv_unwrap<_Tp, reference_wrapper<_Up>> 02309 { 02310 using type = _Up&; 02311 }; 02312 02313 template<bool, bool, typename _Functor, typename... _ArgTypes> 02314 struct __result_of_impl 02315 { 02316 typedef __failure_type type; 02317 }; 02318 02319 template<typename _MemPtr, typename _Arg> 02320 struct __result_of_impl<true, false, _MemPtr, _Arg> 02321 : public __result_of_memobj<typename decay<_MemPtr>::type, 02322 typename __inv_unwrap<_Arg>::type> 02323 { }; 02324 02325 template<typename _MemPtr, typename _Arg, typename... _Args> 02326 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> 02327 : public __result_of_memfun<typename decay<_MemPtr>::type, 02328 typename __inv_unwrap<_Arg>::type, _Args...> 02329 { }; 02330 02331 // [func.require] paragraph 1 bullet 5: 02332 struct __result_of_other_impl 02333 { 02334 template<typename _Fn, typename... _Args> 02335 static __result_of_success<decltype( 02336 std::declval<_Fn>()(std::declval<_Args>()...) 02337 ), __invoke_other> _S_test(int); 02338 02339 template<typename...> 02340 static __failure_type _S_test(...); 02341 }; 02342 02343 template<typename _Functor, typename... _ArgTypes> 02344 struct __result_of_impl<false, false, _Functor, _ArgTypes...> 02345 : private __result_of_other_impl 02346 { 02347 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; 02348 }; 02349 02350 // __invoke_result (std::invoke_result for C++11) 02351 template<typename _Functor, typename... _ArgTypes> 02352 struct __invoke_result 02353 : public __result_of_impl< 02354 is_member_object_pointer< 02355 typename remove_reference<_Functor>::type 02356 >::value, 02357 is_member_function_pointer< 02358 typename remove_reference<_Functor>::type 02359 >::value, 02360 _Functor, _ArgTypes... 02361 >::type 02362 { }; 02363 02364 template<typename _Functor, typename... _ArgTypes> 02365 struct result_of<_Functor(_ArgTypes...)> 02366 : public __invoke_result<_Functor, _ArgTypes...> 02367 { }; 02368 02369 #if __cplusplus >= 201402L 02370 /// Alias template for aligned_storage 02371 template<size_t _Len, size_t _Align = 02372 __alignof__(typename __aligned_storage_msa<_Len>::__type)> 02373 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; 02374 02375 template <size_t _Len, typename... _Types> 02376 using aligned_union_t = typename aligned_union<_Len, _Types...>::type; 02377 02378 /// Alias template for decay 02379 template<typename _Tp> 02380 using decay_t = typename decay<_Tp>::type; 02381 02382 /// Alias template for enable_if 02383 template<bool _Cond, typename _Tp = void> 02384 using enable_if_t = typename enable_if<_Cond, _Tp>::type; 02385 02386 /// Alias template for conditional 02387 template<bool _Cond, typename _Iftrue, typename _Iffalse> 02388 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; 02389 02390 /// Alias template for common_type 02391 template<typename... _Tp> 02392 using common_type_t = typename common_type<_Tp...>::type; 02393 02394 /// Alias template for underlying_type 02395 template<typename _Tp> 02396 using underlying_type_t = typename underlying_type<_Tp>::type; 02397 02398 /// Alias template for result_of 02399 template<typename _Tp> 02400 using result_of_t = typename result_of<_Tp>::type; 02401 #endif // C++14 02402 02403 // __enable_if_t (std::enable_if_t for C++11) 02404 template<bool _Cond, typename _Tp = void> 02405 using __enable_if_t = typename enable_if<_Cond, _Tp>::type; 02406 02407 // __void_t (std::void_t for C++11) 02408 template<typename...> using __void_t = void; 02409 02410 #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 02411 #define __cpp_lib_void_t 201411 02412 /// A metafunction that always yields void, used for detecting valid types. 02413 template<typename...> using void_t = void; 02414 #endif 02415 02416 /// Implementation of the detection idiom (negative case). 02417 template<typename _Default, typename _AlwaysVoid, 02418 template<typename...> class _Op, typename... _Args> 02419 struct __detector 02420 { 02421 using value_t = false_type; 02422 using type = _Default; 02423 }; 02424 02425 /// Implementation of the detection idiom (positive case). 02426 template<typename _Default, template<typename...> class _Op, 02427 typename... _Args> 02428 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> 02429 { 02430 using value_t = true_type; 02431 using type = _Op<_Args...>; 02432 }; 02433 02434 // Detect whether _Op<_Args...> is a valid type, use _Default if not. 02435 template<typename _Default, template<typename...> class _Op, 02436 typename... _Args> 02437 using __detected_or = __detector<_Default, void, _Op, _Args...>; 02438 02439 // _Op<_Args...> if that is a valid type, otherwise _Default. 02440 template<typename _Default, template<typename...> class _Op, 02441 typename... _Args> 02442 using __detected_or_t 02443 = typename __detected_or<_Default, _Op, _Args...>::type; 02444 02445 /// @} group metaprogramming 02446 02447 /** 02448 * Use SFINAE to determine if the type _Tp has a publicly-accessible 02449 * member type _NTYPE. 02450 */ 02451 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ 02452 template<typename _Tp, typename = __void_t<>> \ 02453 struct __has_##_NTYPE \ 02454 : false_type \ 02455 { }; \ 02456 template<typename _Tp> \ 02457 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ 02458 : true_type \ 02459 { }; 02460 02461 template <typename _Tp> 02462 struct __is_swappable; 02463 02464 template <typename _Tp> 02465 struct __is_nothrow_swappable; 02466 02467 template<typename... _Elements> 02468 class tuple; 02469 02470 template<typename> 02471 struct __is_tuple_like_impl : false_type 02472 { }; 02473 02474 template<typename... _Tps> 02475 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type 02476 { }; 02477 02478 // Internal type trait that allows us to sfinae-protect tuple_cat. 02479 template<typename _Tp> 02480 struct __is_tuple_like 02481 : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type 02482 { }; 02483 02484 template<typename _Tp> 02485 inline 02486 typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>, 02487 is_move_constructible<_Tp>, 02488 is_move_assignable<_Tp>>::value>::type 02489 swap(_Tp&, _Tp&) 02490 noexcept(__and_<is_nothrow_move_constructible<_Tp>, 02491 is_nothrow_move_assignable<_Tp>>::value); 02492 02493 template<typename _Tp, size_t _Nm> 02494 inline 02495 typename enable_if<__is_swappable<_Tp>::value>::type 02496 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) 02497 noexcept(__is_nothrow_swappable<_Tp>::value); 02498 02499 namespace __swappable_details { 02500 using std::swap; 02501 02502 struct __do_is_swappable_impl 02503 { 02504 template<typename _Tp, typename 02505 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> 02506 static true_type __test(int); 02507 02508 template<typename> 02509 static false_type __test(...); 02510 }; 02511 02512 struct __do_is_nothrow_swappable_impl 02513 { 02514 template<typename _Tp> 02515 static __bool_constant< 02516 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) 02517 > __test(int); 02518 02519 template<typename> 02520 static false_type __test(...); 02521 }; 02522 02523 } // namespace __swappable_details 02524 02525 template<typename _Tp> 02526 struct __is_swappable_impl 02527 : public __swappable_details::__do_is_swappable_impl 02528 { 02529 typedef decltype(__test<_Tp>(0)) type; 02530 }; 02531 02532 template<typename _Tp> 02533 struct __is_nothrow_swappable_impl 02534 : public __swappable_details::__do_is_nothrow_swappable_impl 02535 { 02536 typedef decltype(__test<_Tp>(0)) type; 02537 }; 02538 02539 template<typename _Tp> 02540 struct __is_swappable 02541 : public __is_swappable_impl<_Tp>::type 02542 { }; 02543 02544 template<typename _Tp> 02545 struct __is_nothrow_swappable 02546 : public __is_nothrow_swappable_impl<_Tp>::type 02547 { }; 02548 02549 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 02550 #define __cpp_lib_is_swappable 201603 02551 /// Metafunctions used for detecting swappable types: p0185r1 02552 02553 /// is_swappable 02554 template<typename _Tp> 02555 struct is_swappable 02556 : public __is_swappable_impl<_Tp>::type 02557 { }; 02558 02559 /// is_nothrow_swappable 02560 template<typename _Tp> 02561 struct is_nothrow_swappable 02562 : public __is_nothrow_swappable_impl<_Tp>::type 02563 { }; 02564 02565 #if __cplusplus >= 201402L 02566 /// is_swappable_v 02567 template<typename _Tp> 02568 _GLIBCXX17_INLINE constexpr bool is_swappable_v = 02569 is_swappable<_Tp>::value; 02570 02571 /// is_nothrow_swappable_v 02572 template<typename _Tp> 02573 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = 02574 is_nothrow_swappable<_Tp>::value; 02575 #endif // __cplusplus >= 201402L 02576 02577 namespace __swappable_with_details { 02578 using std::swap; 02579 02580 struct __do_is_swappable_with_impl 02581 { 02582 template<typename _Tp, typename _Up, typename 02583 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), 02584 typename 02585 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> 02586 static true_type __test(int); 02587 02588 template<typename, typename> 02589 static false_type __test(...); 02590 }; 02591 02592 struct __do_is_nothrow_swappable_with_impl 02593 { 02594 template<typename _Tp, typename _Up> 02595 static __bool_constant< 02596 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) 02597 && 02598 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) 02599 > __test(int); 02600 02601 template<typename, typename> 02602 static false_type __test(...); 02603 }; 02604 02605 } // namespace __swappable_with_details 02606 02607 template<typename _Tp, typename _Up> 02608 struct __is_swappable_with_impl 02609 : public __swappable_with_details::__do_is_swappable_with_impl 02610 { 02611 typedef decltype(__test<_Tp, _Up>(0)) type; 02612 }; 02613 02614 // Optimization for the homogenous lvalue case, not required: 02615 template<typename _Tp> 02616 struct __is_swappable_with_impl<_Tp&, _Tp&> 02617 : public __swappable_details::__do_is_swappable_impl 02618 { 02619 typedef decltype(__test<_Tp&>(0)) type; 02620 }; 02621 02622 template<typename _Tp, typename _Up> 02623 struct __is_nothrow_swappable_with_impl 02624 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl 02625 { 02626 typedef decltype(__test<_Tp, _Up>(0)) type; 02627 }; 02628 02629 // Optimization for the homogenous lvalue case, not required: 02630 template<typename _Tp> 02631 struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> 02632 : public __swappable_details::__do_is_nothrow_swappable_impl 02633 { 02634 typedef decltype(__test<_Tp&>(0)) type; 02635 }; 02636 02637 /// is_swappable_with 02638 template<typename _Tp, typename _Up> 02639 struct is_swappable_with 02640 : public __is_swappable_with_impl<_Tp, _Up>::type 02641 { }; 02642 02643 /// is_nothrow_swappable_with 02644 template<typename _Tp, typename _Up> 02645 struct is_nothrow_swappable_with 02646 : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type 02647 { }; 02648 02649 #if __cplusplus >= 201402L 02650 /// is_swappable_with_v 02651 template<typename _Tp, typename _Up> 02652 _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = 02653 is_swappable_with<_Tp, _Up>::value; 02654 02655 /// is_nothrow_swappable_with_v 02656 template<typename _Tp, typename _Up> 02657 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = 02658 is_nothrow_swappable_with<_Tp, _Up>::value; 02659 #endif // __cplusplus >= 201402L 02660 02661 #endif// c++1z or gnu++11 02662 02663 // __is_invocable (std::is_invocable for C++11) 02664 02665 template<typename _Result, typename _Ret, typename = void> 02666 struct __is_invocable_impl : false_type { }; 02667 02668 template<typename _Result, typename _Ret> 02669 struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>> 02670 : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type 02671 { }; 02672 02673 template<typename _Fn, typename... _ArgTypes> 02674 struct __is_invocable 02675 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type 02676 { }; 02677 02678 template<typename _Fn, typename _Tp, typename... _Args> 02679 constexpr bool __call_is_nt(__invoke_memfun_ref) 02680 { 02681 using _Up = typename __inv_unwrap<_Tp>::type; 02682 return noexcept((std::declval<_Up>().*std::declval<_Fn>())( 02683 std::declval<_Args>()...)); 02684 } 02685 02686 template<typename _Fn, typename _Tp, typename... _Args> 02687 constexpr bool __call_is_nt(__invoke_memfun_deref) 02688 { 02689 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( 02690 std::declval<_Args>()...)); 02691 } 02692 02693 template<typename _Fn, typename _Tp> 02694 constexpr bool __call_is_nt(__invoke_memobj_ref) 02695 { 02696 using _Up = typename __inv_unwrap<_Tp>::type; 02697 return noexcept(std::declval<_Up>().*std::declval<_Fn>()); 02698 } 02699 02700 template<typename _Fn, typename _Tp> 02701 constexpr bool __call_is_nt(__invoke_memobj_deref) 02702 { 02703 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); 02704 } 02705 02706 template<typename _Fn, typename... _Args> 02707 constexpr bool __call_is_nt(__invoke_other) 02708 { 02709 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); 02710 } 02711 02712 template<typename _Result, typename _Fn, typename... _Args> 02713 struct __call_is_nothrow 02714 : __bool_constant< 02715 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) 02716 > 02717 { }; 02718 02719 template<typename _Fn, typename... _Args> 02720 using __call_is_nothrow_ 02721 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; 02722 02723 // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) 02724 template<typename _Fn, typename... _Args> 02725 struct __is_nothrow_invocable 02726 : __and_<__is_invocable<_Fn, _Args...>, 02727 __call_is_nothrow_<_Fn, _Args...>>::type 02728 { }; 02729 02730 struct __nonesuch { 02731 __nonesuch() = delete; 02732 ~__nonesuch() = delete; 02733 __nonesuch(__nonesuch const&) = delete; 02734 void operator=(__nonesuch const&) = delete; 02735 }; 02736 02737 #if __cplusplus >= 201703L 02738 # define __cpp_lib_is_invocable 201703 02739 02740 /// std::invoke_result 02741 template<typename _Functor, typename... _ArgTypes> 02742 struct invoke_result 02743 : public __invoke_result<_Functor, _ArgTypes...> 02744 { }; 02745 02746 /// std::invoke_result_t 02747 template<typename _Fn, typename... _Args> 02748 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; 02749 02750 /// std::is_invocable 02751 template<typename _Fn, typename... _ArgTypes> 02752 struct is_invocable 02753 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type 02754 { }; 02755 02756 /// std::is_invocable_r 02757 template<typename _Ret, typename _Fn, typename... _ArgTypes> 02758 struct is_invocable_r 02759 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type 02760 { }; 02761 02762 /// std::is_nothrow_invocable 02763 template<typename _Fn, typename... _ArgTypes> 02764 struct is_nothrow_invocable 02765 : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, 02766 __call_is_nothrow_<_Fn, _ArgTypes...>>::type 02767 { }; 02768 02769 template<typename _Result, typename _Ret, typename = void> 02770 struct __is_nt_invocable_impl : false_type { }; 02771 02772 template<typename _Result, typename _Ret> 02773 struct __is_nt_invocable_impl<_Result, _Ret, 02774 __void_t<typename _Result::type>> 02775 : __or_<is_void<_Ret>, 02776 __and_<is_convertible<typename _Result::type, _Ret>, 02777 is_nothrow_constructible<_Ret, typename _Result::type>>> 02778 { }; 02779 02780 /// std::is_nothrow_invocable_r 02781 template<typename _Ret, typename _Fn, typename... _ArgTypes> 02782 struct is_nothrow_invocable_r 02783 : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, 02784 __call_is_nothrow_<_Fn, _ArgTypes...>>::type 02785 { }; 02786 02787 /// std::is_invocable_v 02788 template<typename _Fn, typename... _Args> 02789 inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; 02790 02791 /// std::is_nothrow_invocable_v 02792 template<typename _Fn, typename... _Args> 02793 inline constexpr bool is_nothrow_invocable_v 02794 = is_nothrow_invocable<_Fn, _Args...>::value; 02795 02796 /// std::is_invocable_r_v 02797 template<typename _Fn, typename... _Args> 02798 inline constexpr bool is_invocable_r_v 02799 = is_invocable_r<_Fn, _Args...>::value; 02800 02801 /// std::is_nothrow_invocable_r_v 02802 template<typename _Fn, typename... _Args> 02803 inline constexpr bool is_nothrow_invocable_r_v 02804 = is_nothrow_invocable_r<_Fn, _Args...>::value; 02805 #endif // C++17 02806 02807 #if __cplusplus >= 201703L 02808 # define __cpp_lib_type_trait_variable_templates 201510L 02809 template <typename _Tp> 02810 inline constexpr bool is_void_v = is_void<_Tp>::value; 02811 template <typename _Tp> 02812 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; 02813 template <typename _Tp> 02814 inline constexpr bool is_integral_v = is_integral<_Tp>::value; 02815 template <typename _Tp> 02816 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; 02817 template <typename _Tp> 02818 inline constexpr bool is_array_v = is_array<_Tp>::value; 02819 template <typename _Tp> 02820 inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; 02821 template <typename _Tp> 02822 inline constexpr bool is_lvalue_reference_v = 02823 is_lvalue_reference<_Tp>::value; 02824 template <typename _Tp> 02825 inline constexpr bool is_rvalue_reference_v = 02826 is_rvalue_reference<_Tp>::value; 02827 template <typename _Tp> 02828 inline constexpr bool is_member_object_pointer_v = 02829 is_member_object_pointer<_Tp>::value; 02830 template <typename _Tp> 02831 inline constexpr bool is_member_function_pointer_v = 02832 is_member_function_pointer<_Tp>::value; 02833 template <typename _Tp> 02834 inline constexpr bool is_enum_v = is_enum<_Tp>::value; 02835 template <typename _Tp> 02836 inline constexpr bool is_union_v = is_union<_Tp>::value; 02837 template <typename _Tp> 02838 inline constexpr bool is_class_v = is_class<_Tp>::value; 02839 template <typename _Tp> 02840 inline constexpr bool is_function_v = is_function<_Tp>::value; 02841 template <typename _Tp> 02842 inline constexpr bool is_reference_v = is_reference<_Tp>::value; 02843 template <typename _Tp> 02844 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; 02845 template <typename _Tp> 02846 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; 02847 template <typename _Tp> 02848 inline constexpr bool is_object_v = is_object<_Tp>::value; 02849 template <typename _Tp> 02850 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; 02851 template <typename _Tp> 02852 inline constexpr bool is_compound_v = is_compound<_Tp>::value; 02853 template <typename _Tp> 02854 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; 02855 template <typename _Tp> 02856 inline constexpr bool is_const_v = is_const<_Tp>::value; 02857 template <typename _Tp> 02858 inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; 02859 template <typename _Tp> 02860 inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; 02861 template <typename _Tp> 02862 inline constexpr bool is_trivially_copyable_v = 02863 is_trivially_copyable<_Tp>::value; 02864 template <typename _Tp> 02865 inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; 02866 template <typename _Tp> 02867 inline constexpr bool is_pod_v = is_pod<_Tp>::value; 02868 template <typename _Tp> 02869 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; 02870 template <typename _Tp> 02871 inline constexpr bool is_empty_v = is_empty<_Tp>::value; 02872 template <typename _Tp> 02873 inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; 02874 template <typename _Tp> 02875 inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; 02876 template <typename _Tp> 02877 inline constexpr bool is_final_v = is_final<_Tp>::value; 02878 template <typename _Tp> 02879 inline constexpr bool is_signed_v = is_signed<_Tp>::value; 02880 template <typename _Tp> 02881 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; 02882 template <typename _Tp, typename... _Args> 02883 inline constexpr bool is_constructible_v = 02884 is_constructible<_Tp, _Args...>::value; 02885 template <typename _Tp> 02886 inline constexpr bool is_default_constructible_v = 02887 is_default_constructible<_Tp>::value; 02888 template <typename _Tp> 02889 inline constexpr bool is_copy_constructible_v = 02890 is_copy_constructible<_Tp>::value; 02891 template <typename _Tp> 02892 inline constexpr bool is_move_constructible_v = 02893 is_move_constructible<_Tp>::value; 02894 template <typename _Tp, typename _Up> 02895 inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; 02896 template <typename _Tp> 02897 inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; 02898 template <typename _Tp> 02899 inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; 02900 template <typename _Tp> 02901 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; 02902 template <typename _Tp, typename... _Args> 02903 inline constexpr bool is_trivially_constructible_v = 02904 is_trivially_constructible<_Tp, _Args...>::value; 02905 template <typename _Tp> 02906 inline constexpr bool is_trivially_default_constructible_v = 02907 is_trivially_default_constructible<_Tp>::value; 02908 template <typename _Tp> 02909 inline constexpr bool is_trivially_copy_constructible_v = 02910 is_trivially_copy_constructible<_Tp>::value; 02911 template <typename _Tp> 02912 inline constexpr bool is_trivially_move_constructible_v = 02913 is_trivially_move_constructible<_Tp>::value; 02914 template <typename _Tp, typename _Up> 02915 inline constexpr bool is_trivially_assignable_v = 02916 is_trivially_assignable<_Tp, _Up>::value; 02917 template <typename _Tp> 02918 inline constexpr bool is_trivially_copy_assignable_v = 02919 is_trivially_copy_assignable<_Tp>::value; 02920 template <typename _Tp> 02921 inline constexpr bool is_trivially_move_assignable_v = 02922 is_trivially_move_assignable<_Tp>::value; 02923 template <typename _Tp> 02924 inline constexpr bool is_trivially_destructible_v = 02925 is_trivially_destructible<_Tp>::value; 02926 template <typename _Tp, typename... _Args> 02927 inline constexpr bool is_nothrow_constructible_v = 02928 is_nothrow_constructible<_Tp, _Args...>::value; 02929 template <typename _Tp> 02930 inline constexpr bool is_nothrow_default_constructible_v = 02931 is_nothrow_default_constructible<_Tp>::value; 02932 template <typename _Tp> 02933 inline constexpr bool is_nothrow_copy_constructible_v = 02934 is_nothrow_copy_constructible<_Tp>::value; 02935 template <typename _Tp> 02936 inline constexpr bool is_nothrow_move_constructible_v = 02937 is_nothrow_move_constructible<_Tp>::value; 02938 template <typename _Tp, typename _Up> 02939 inline constexpr bool is_nothrow_assignable_v = 02940 is_nothrow_assignable<_Tp, _Up>::value; 02941 template <typename _Tp> 02942 inline constexpr bool is_nothrow_copy_assignable_v = 02943 is_nothrow_copy_assignable<_Tp>::value; 02944 template <typename _Tp> 02945 inline constexpr bool is_nothrow_move_assignable_v = 02946 is_nothrow_move_assignable<_Tp>::value; 02947 template <typename _Tp> 02948 inline constexpr bool is_nothrow_destructible_v = 02949 is_nothrow_destructible<_Tp>::value; 02950 template <typename _Tp> 02951 inline constexpr bool has_virtual_destructor_v = 02952 has_virtual_destructor<_Tp>::value; 02953 template <typename _Tp> 02954 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; 02955 template <typename _Tp> 02956 inline constexpr size_t rank_v = rank<_Tp>::value; 02957 template <typename _Tp, unsigned _Idx = 0> 02958 inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; 02959 template <typename _Tp, typename _Up> 02960 inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; 02961 template <typename _Base, typename _Derived> 02962 inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; 02963 template <typename _From, typename _To> 02964 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; 02965 02966 #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 02967 # define __cpp_lib_has_unique_object_representations 201606 02968 /// has_unique_object_representations 02969 template<typename _Tp> 02970 struct has_unique_object_representations 02971 : bool_constant<__has_unique_object_representations( 02972 remove_cv_t<remove_all_extents_t<_Tp>> 02973 )> 02974 { }; 02975 02976 template<typename _Tp> 02977 inline constexpr bool has_unique_object_representations_v 02978 = has_unique_object_representations<_Tp>::value; 02979 #endif 02980 02981 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 02982 # define __cpp_lib_is_aggregate 201703 02983 /// is_aggregate 02984 template<typename _Tp> 02985 struct is_aggregate 02986 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { }; 02987 02988 /// is_aggregate_v 02989 template<typename _Tp> 02990 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; 02991 #endif 02992 #endif // C++17 02993 02994 #if __cplusplus > 201703L 02995 /// Byte order 02996 enum class endian 02997 { 02998 little = __ORDER_LITTLE_ENDIAN__, 02999 big = __ORDER_BIG_ENDIAN__, 03000 native = __BYTE_ORDER__ 03001 }; 03002 03003 /// Remove references and cv-qualifiers. 03004 template<typename _Tp> 03005 struct remove_cvref 03006 { 03007 using type = __remove_cvref_t<_Tp>; 03008 }; 03009 03010 template<typename _Tp> 03011 using remove_cvref_t = __remove_cvref_t<_Tp>; 03012 03013 /// Identity metafunction. 03014 template<typename _Tp> 03015 struct type_identity { using type = _Tp; }; 03016 03017 template<typename _Tp> 03018 using type_identity_t = typename type_identity<_Tp>::type; 03019 03020 /// Unwrap a reference_wrapper 03021 template<typename _Tp> 03022 struct unwrap_reference { using type = _Tp; }; 03023 03024 template<typename _Tp> 03025 struct unwrap_reference<reference_wrapper<_Tp>> { using type = _Tp&; }; 03026 03027 template<typename _Tp> 03028 using unwrap_reference_t = typename unwrap_reference<_Tp>::type; 03029 03030 /// Decay type and if it's a reference_wrapper, unwrap it 03031 template<typename _Tp> 03032 struct unwrap_ref_decay { using type = unwrap_reference_t<decay_t<_Tp>>; }; 03033 03034 template<typename _Tp> 03035 using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; 03036 03037 #define __cpp_lib_bounded_array_traits 201902L 03038 03039 /// True for a type that is an array of known bound. 03040 template<typename _Tp> 03041 struct is_bounded_array 03042 : public __is_array_known_bounds<_Tp> 03043 { }; 03044 03045 /// True for a type that is an array of unknown bound. 03046 template<typename _Tp> 03047 struct is_unbounded_array 03048 : public __is_array_unknown_bounds<_Tp> 03049 { }; 03050 03051 template<typename _Tp> 03052 inline constexpr bool is_bounded_array_v 03053 = is_bounded_array<_Tp>::value; 03054 03055 template<typename _Tp> 03056 inline constexpr bool is_unbounded_array_v 03057 = is_unbounded_array<_Tp>::value; 03058 03059 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 03060 03061 #define __cpp_lib_is_constant_evaluated 201811L 03062 03063 constexpr inline bool 03064 is_constant_evaluated() noexcept 03065 { return __builtin_is_constant_evaluated(); } 03066 #endif 03067 03068 #endif // C++2a 03069 03070 _GLIBCXX_END_NAMESPACE_VERSION 03071 } // namespace std 03072 03073 #endif // C++11 03074 03075 #endif // _GLIBCXX_TYPE_TRAITS