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