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) 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 struct __do_is_default_constructible_impl 00871 { 00872 template<typename _Tp, typename = decltype(_Tp())> 00873 static true_type __test(int); 00874 00875 template<typename> 00876 static false_type __test(...); 00877 }; 00878 00879 template<typename _Tp> 00880 struct __is_default_constructible_impl 00881 : public __do_is_default_constructible_impl 00882 { 00883 typedef decltype(__test<_Tp>(0)) type; 00884 }; 00885 00886 template<typename _Tp> 00887 struct __is_default_constructible_atom 00888 : public __and_<__not_<is_void<_Tp>>, 00889 __is_default_constructible_impl<_Tp>> 00890 { }; 00891 00892 template<typename _Tp, bool = is_array<_Tp>::value> 00893 struct __is_default_constructible_safe; 00894 00895 // The following technique is a workaround for a current core language 00896 // restriction, which does not allow for array types to occur in 00897 // functional casts of the form T(). Complete arrays can be default- 00898 // constructed, if the element type is default-constructible, but 00899 // arrays with unknown bounds are not. 00900 template<typename _Tp> 00901 struct __is_default_constructible_safe<_Tp, true> 00902 : public __and_<__is_array_known_bounds<_Tp>, 00903 __is_default_constructible_atom<typename 00904 remove_all_extents<_Tp>::type>> 00905 { }; 00906 00907 template<typename _Tp> 00908 struct __is_default_constructible_safe<_Tp, false> 00909 : public __is_default_constructible_atom<_Tp>::type 00910 { }; 00911 00912 /// is_default_constructible 00913 template<typename _Tp> 00914 struct is_default_constructible 00915 : public __is_default_constructible_safe<_Tp>::type 00916 { }; 00917 00918 /// is_constructible 00919 template<typename _Tp, typename... _Args> 00920 struct is_constructible 00921 : public __bool_constant<__is_constructible(_Tp, _Args...)> 00922 { }; 00923 00924 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 00925 struct __is_copy_constructible_impl; 00926 00927 template<typename _Tp> 00928 struct __is_copy_constructible_impl<_Tp, false> 00929 : public false_type { }; 00930 00931 template<typename _Tp> 00932 struct __is_copy_constructible_impl<_Tp, true> 00933 : public is_constructible<_Tp, const _Tp&> 00934 { }; 00935 00936 /// is_copy_constructible 00937 template<typename _Tp> 00938 struct is_copy_constructible 00939 : public __is_copy_constructible_impl<_Tp> 00940 { }; 00941 00942 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 00943 struct __is_move_constructible_impl; 00944 00945 template<typename _Tp> 00946 struct __is_move_constructible_impl<_Tp, false> 00947 : public false_type { }; 00948 00949 template<typename _Tp> 00950 struct __is_move_constructible_impl<_Tp, true> 00951 : public is_constructible<_Tp, _Tp&&> 00952 { }; 00953 00954 /// is_move_constructible 00955 template<typename _Tp> 00956 struct is_move_constructible 00957 : public __is_move_constructible_impl<_Tp> 00958 { }; 00959 00960 template<typename _Tp> 00961 struct __is_nt_default_constructible_atom 00962 : public integral_constant<bool, noexcept(_Tp())> 00963 { }; 00964 00965 template<typename _Tp, bool = is_array<_Tp>::value> 00966 struct __is_nt_default_constructible_impl; 00967 00968 template<typename _Tp> 00969 struct __is_nt_default_constructible_impl<_Tp, true> 00970 : public __and_<__is_array_known_bounds<_Tp>, 00971 __is_nt_default_constructible_atom<typename 00972 remove_all_extents<_Tp>::type>> 00973 { }; 00974 00975 template<typename _Tp> 00976 struct __is_nt_default_constructible_impl<_Tp, false> 00977 : public __is_nt_default_constructible_atom<_Tp> 00978 { }; 00979 00980 /// is_nothrow_default_constructible 00981 template<typename _Tp> 00982 struct is_nothrow_default_constructible 00983 : public __and_<is_default_constructible<_Tp>, 00984 __is_nt_default_constructible_impl<_Tp>> 00985 { }; 00986 00987 template<typename _Tp, typename... _Args> 00988 struct __is_nt_constructible_impl 00989 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> 00990 { }; 00991 00992 template<typename _Tp, typename _Arg> 00993 struct __is_nt_constructible_impl<_Tp, _Arg> 00994 : public integral_constant<bool, 00995 noexcept(static_cast<_Tp>(declval<_Arg>()))> 00996 { }; 00997 00998 template<typename _Tp> 00999 struct __is_nt_constructible_impl<_Tp> 01000 : public is_nothrow_default_constructible<_Tp> 01001 { }; 01002 01003 /// is_nothrow_constructible 01004 template<typename _Tp, typename... _Args> 01005 struct is_nothrow_constructible 01006 : public __and_<is_constructible<_Tp, _Args...>, 01007 __is_nt_constructible_impl<_Tp, _Args...>> 01008 { }; 01009 01010 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01011 struct __is_nothrow_copy_constructible_impl; 01012 01013 template<typename _Tp> 01014 struct __is_nothrow_copy_constructible_impl<_Tp, false> 01015 : public false_type { }; 01016 01017 template<typename _Tp> 01018 struct __is_nothrow_copy_constructible_impl<_Tp, true> 01019 : public is_nothrow_constructible<_Tp, const _Tp&> 01020 { }; 01021 01022 /// is_nothrow_copy_constructible 01023 template<typename _Tp> 01024 struct is_nothrow_copy_constructible 01025 : public __is_nothrow_copy_constructible_impl<_Tp> 01026 { }; 01027 01028 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01029 struct __is_nothrow_move_constructible_impl; 01030 01031 template<typename _Tp> 01032 struct __is_nothrow_move_constructible_impl<_Tp, false> 01033 : public false_type { }; 01034 01035 template<typename _Tp> 01036 struct __is_nothrow_move_constructible_impl<_Tp, true> 01037 : public is_nothrow_constructible<_Tp, _Tp&&> 01038 { }; 01039 01040 /// is_nothrow_move_constructible 01041 template<typename _Tp> 01042 struct is_nothrow_move_constructible 01043 : public __is_nothrow_move_constructible_impl<_Tp> 01044 { }; 01045 01046 /// is_assignable 01047 template<typename _Tp, typename _Up> 01048 struct is_assignable 01049 : public __bool_constant<__is_assignable(_Tp, _Up)> 01050 { }; 01051 01052 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01053 struct __is_copy_assignable_impl; 01054 01055 template<typename _Tp> 01056 struct __is_copy_assignable_impl<_Tp, false> 01057 : public false_type { }; 01058 01059 template<typename _Tp> 01060 struct __is_copy_assignable_impl<_Tp, true> 01061 : public is_assignable<_Tp&, const _Tp&> 01062 { }; 01063 01064 /// is_copy_assignable 01065 template<typename _Tp> 01066 struct is_copy_assignable 01067 : public __is_copy_assignable_impl<_Tp> 01068 { }; 01069 01070 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01071 struct __is_move_assignable_impl; 01072 01073 template<typename _Tp> 01074 struct __is_move_assignable_impl<_Tp, false> 01075 : public false_type { }; 01076 01077 template<typename _Tp> 01078 struct __is_move_assignable_impl<_Tp, true> 01079 : public is_assignable<_Tp&, _Tp&&> 01080 { }; 01081 01082 /// is_move_assignable 01083 template<typename _Tp> 01084 struct is_move_assignable 01085 : public __is_move_assignable_impl<_Tp> 01086 { }; 01087 01088 template<typename _Tp, typename _Up> 01089 struct __is_nt_assignable_impl 01090 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())> 01091 { }; 01092 01093 /// is_nothrow_assignable 01094 template<typename _Tp, typename _Up> 01095 struct is_nothrow_assignable 01096 : public __and_<is_assignable<_Tp, _Up>, 01097 __is_nt_assignable_impl<_Tp, _Up>> 01098 { }; 01099 01100 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01101 struct __is_nt_copy_assignable_impl; 01102 01103 template<typename _Tp> 01104 struct __is_nt_copy_assignable_impl<_Tp, false> 01105 : public false_type { }; 01106 01107 template<typename _Tp> 01108 struct __is_nt_copy_assignable_impl<_Tp, true> 01109 : public is_nothrow_assignable<_Tp&, const _Tp&> 01110 { }; 01111 01112 /// is_nothrow_copy_assignable 01113 template<typename _Tp> 01114 struct is_nothrow_copy_assignable 01115 : public __is_nt_copy_assignable_impl<_Tp> 01116 { }; 01117 01118 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01119 struct __is_nt_move_assignable_impl; 01120 01121 template<typename _Tp> 01122 struct __is_nt_move_assignable_impl<_Tp, false> 01123 : public false_type { }; 01124 01125 template<typename _Tp> 01126 struct __is_nt_move_assignable_impl<_Tp, true> 01127 : public is_nothrow_assignable<_Tp&, _Tp&&> 01128 { }; 01129 01130 /// is_nothrow_move_assignable 01131 template<typename _Tp> 01132 struct is_nothrow_move_assignable 01133 : public __is_nt_move_assignable_impl<_Tp> 01134 { }; 01135 01136 /// is_trivially_constructible 01137 template<typename _Tp, typename... _Args> 01138 struct is_trivially_constructible 01139 : public __and_<is_constructible<_Tp, _Args...>, __bool_constant< 01140 __is_trivially_constructible(_Tp, _Args...)>>::type 01141 { }; 01142 01143 /// is_trivially_default_constructible 01144 template<typename _Tp> 01145 struct is_trivially_default_constructible 01146 : public is_trivially_constructible<_Tp>::type 01147 { }; 01148 01149 struct __do_is_implicitly_default_constructible_impl 01150 { 01151 template <typename _Tp> 01152 static void __helper(const _Tp&); 01153 01154 template <typename _Tp> 01155 static true_type __test(const _Tp&, 01156 decltype(__helper<const _Tp&>({}))* = 0); 01157 01158 static false_type __test(...); 01159 }; 01160 01161 template<typename _Tp> 01162 struct __is_implicitly_default_constructible_impl 01163 : public __do_is_implicitly_default_constructible_impl 01164 { 01165 typedef decltype(__test(declval<_Tp>())) type; 01166 }; 01167 01168 template<typename _Tp> 01169 struct __is_implicitly_default_constructible_safe 01170 : public __is_implicitly_default_constructible_impl<_Tp>::type 01171 { }; 01172 01173 template <typename _Tp> 01174 struct __is_implicitly_default_constructible 01175 : public __and_<is_default_constructible<_Tp>, 01176 __is_implicitly_default_constructible_safe<_Tp>> 01177 { }; 01178 01179 /// is_trivially_copy_constructible 01180 01181 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01182 struct __is_trivially_copy_constructible_impl; 01183 01184 template<typename _Tp> 01185 struct __is_trivially_copy_constructible_impl<_Tp, false> 01186 : public false_type { }; 01187 01188 template<typename _Tp> 01189 struct __is_trivially_copy_constructible_impl<_Tp, true> 01190 : public __and_<is_copy_constructible<_Tp>, 01191 integral_constant<bool, 01192 __is_trivially_constructible(_Tp, const _Tp&)>> 01193 { }; 01194 01195 template<typename _Tp> 01196 struct is_trivially_copy_constructible 01197 : public __is_trivially_copy_constructible_impl<_Tp> 01198 { }; 01199 01200 /// is_trivially_move_constructible 01201 01202 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01203 struct __is_trivially_move_constructible_impl; 01204 01205 template<typename _Tp> 01206 struct __is_trivially_move_constructible_impl<_Tp, false> 01207 : public false_type { }; 01208 01209 template<typename _Tp> 01210 struct __is_trivially_move_constructible_impl<_Tp, true> 01211 : public __and_<is_move_constructible<_Tp>, 01212 integral_constant<bool, 01213 __is_trivially_constructible(_Tp, _Tp&&)>> 01214 { }; 01215 01216 template<typename _Tp> 01217 struct is_trivially_move_constructible 01218 : public __is_trivially_move_constructible_impl<_Tp> 01219 { }; 01220 01221 /// is_trivially_assignable 01222 template<typename _Tp, typename _Up> 01223 struct is_trivially_assignable 01224 : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> 01225 { }; 01226 01227 /// is_trivially_copy_assignable 01228 01229 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01230 struct __is_trivially_copy_assignable_impl; 01231 01232 template<typename _Tp> 01233 struct __is_trivially_copy_assignable_impl<_Tp, false> 01234 : public false_type { }; 01235 01236 template<typename _Tp> 01237 struct __is_trivially_copy_assignable_impl<_Tp, true> 01238 : public __and_<is_copy_assignable<_Tp>, 01239 integral_constant<bool, 01240 __is_trivially_assignable(_Tp&, const _Tp&)>> 01241 { }; 01242 01243 template<typename _Tp> 01244 struct is_trivially_copy_assignable 01245 : public __is_trivially_copy_assignable_impl<_Tp> 01246 { }; 01247 01248 /// is_trivially_move_assignable 01249 01250 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01251 struct __is_trivially_move_assignable_impl; 01252 01253 template<typename _Tp> 01254 struct __is_trivially_move_assignable_impl<_Tp, false> 01255 : public false_type { }; 01256 01257 template<typename _Tp> 01258 struct __is_trivially_move_assignable_impl<_Tp, true> 01259 : public __and_<is_move_assignable<_Tp>, 01260 integral_constant<bool, 01261 __is_trivially_assignable(_Tp&, _Tp&&)>> 01262 { }; 01263 01264 template<typename _Tp> 01265 struct is_trivially_move_assignable 01266 : public __is_trivially_move_assignable_impl<_Tp> 01267 { }; 01268 01269 /// is_trivially_destructible 01270 template<typename _Tp> 01271 struct is_trivially_destructible 01272 : public __and_<is_destructible<_Tp>, integral_constant<bool, 01273 __has_trivial_destructor(_Tp)>> 01274 { }; 01275 01276 01277 /// has_virtual_destructor 01278 template<typename _Tp> 01279 struct has_virtual_destructor 01280 : public integral_constant<bool, __has_virtual_destructor(_Tp)> 01281 { }; 01282 01283 01284 // type property queries. 01285 01286 /// alignment_of 01287 template<typename _Tp> 01288 struct alignment_of 01289 : public integral_constant<std::size_t, __alignof__(_Tp)> { }; 01290 01291 /// rank 01292 template<typename> 01293 struct rank 01294 : public integral_constant<std::size_t, 0> { }; 01295 01296 template<typename _Tp, std::size_t _Size> 01297 struct rank<_Tp[_Size]> 01298 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; 01299 01300 template<typename _Tp> 01301 struct rank<_Tp[]> 01302 : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; 01303 01304 /// extent 01305 template<typename, unsigned _Uint> 01306 struct extent 01307 : public integral_constant<std::size_t, 0> { }; 01308 01309 template<typename _Tp, unsigned _Uint, std::size_t _Size> 01310 struct extent<_Tp[_Size], _Uint> 01311 : public integral_constant<std::size_t, 01312 _Uint == 0 ? _Size : extent<_Tp, 01313 _Uint - 1>::value> 01314 { }; 01315 01316 template<typename _Tp, unsigned _Uint> 01317 struct extent<_Tp[], _Uint> 01318 : public integral_constant<std::size_t, 01319 _Uint == 0 ? 0 : extent<_Tp, 01320 _Uint - 1>::value> 01321 { }; 01322 01323 01324 // Type relations. 01325 01326 /// is_same 01327 template<typename, typename> 01328 struct is_same 01329 : public false_type { }; 01330 01331 template<typename _Tp> 01332 struct is_same<_Tp, _Tp> 01333 : public true_type { }; 01334 01335 /// is_base_of 01336 template<typename _Base, typename _Derived> 01337 struct is_base_of 01338 : public integral_constant<bool, __is_base_of(_Base, _Derived)> 01339 { }; 01340 01341 template<typename _From, typename _To, 01342 bool = __or_<is_void<_From>, is_function<_To>, 01343 is_array<_To>>::value> 01344 struct __is_convertible_helper 01345 { typedef typename is_void<_To>::type type; }; 01346 01347 template<typename _From, typename _To> 01348 class __is_convertible_helper<_From, _To, false> 01349 { 01350 template<typename _To1> 01351 static void __test_aux(_To1); 01352 01353 template<typename _From1, typename _To1, 01354 typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> 01355 static true_type 01356 __test(int); 01357 01358 template<typename, typename> 01359 static false_type 01360 __test(...); 01361 01362 public: 01363 typedef decltype(__test<_From, _To>(0)) type; 01364 }; 01365 01366 01367 /// is_convertible 01368 template<typename _From, typename _To> 01369 struct is_convertible 01370 : public __is_convertible_helper<_From, _To>::type 01371 { }; 01372 01373 01374 // Const-volatile modifications. 01375 01376 /// remove_const 01377 template<typename _Tp> 01378 struct remove_const 01379 { typedef _Tp type; }; 01380 01381 template<typename _Tp> 01382 struct remove_const<_Tp const> 01383 { typedef _Tp type; }; 01384 01385 /// remove_volatile 01386 template<typename _Tp> 01387 struct remove_volatile 01388 { typedef _Tp type; }; 01389 01390 template<typename _Tp> 01391 struct remove_volatile<_Tp volatile> 01392 { typedef _Tp type; }; 01393 01394 /// remove_cv 01395 template<typename _Tp> 01396 struct remove_cv 01397 { 01398 typedef typename 01399 remove_const<typename remove_volatile<_Tp>::type>::type type; 01400 }; 01401 01402 /// add_const 01403 template<typename _Tp> 01404 struct add_const 01405 { typedef _Tp const type; }; 01406 01407 /// add_volatile 01408 template<typename _Tp> 01409 struct add_volatile 01410 { typedef _Tp volatile type; }; 01411 01412 /// add_cv 01413 template<typename _Tp> 01414 struct add_cv 01415 { 01416 typedef typename 01417 add_const<typename add_volatile<_Tp>::type>::type type; 01418 }; 01419 01420 #if __cplusplus > 201103L 01421 01422 #define __cpp_lib_transformation_trait_aliases 201304 01423 01424 /// Alias template for remove_const 01425 template<typename _Tp> 01426 using remove_const_t = typename remove_const<_Tp>::type; 01427 01428 /// Alias template for remove_volatile 01429 template<typename _Tp> 01430 using remove_volatile_t = typename remove_volatile<_Tp>::type; 01431 01432 /// Alias template for remove_cv 01433 template<typename _Tp> 01434 using remove_cv_t = typename remove_cv<_Tp>::type; 01435 01436 /// Alias template for add_const 01437 template<typename _Tp> 01438 using add_const_t = typename add_const<_Tp>::type; 01439 01440 /// Alias template for add_volatile 01441 template<typename _Tp> 01442 using add_volatile_t = typename add_volatile<_Tp>::type; 01443 01444 /// Alias template for add_cv 01445 template<typename _Tp> 01446 using add_cv_t = typename add_cv<_Tp>::type; 01447 #endif 01448 01449 // Reference transformations. 01450 01451 /// remove_reference 01452 template<typename _Tp> 01453 struct remove_reference 01454 { typedef _Tp type; }; 01455 01456 template<typename _Tp> 01457 struct remove_reference<_Tp&> 01458 { typedef _Tp type; }; 01459 01460 template<typename _Tp> 01461 struct remove_reference<_Tp&&> 01462 { typedef _Tp type; }; 01463 01464 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01465 struct __add_lvalue_reference_helper 01466 { typedef _Tp type; }; 01467 01468 template<typename _Tp> 01469 struct __add_lvalue_reference_helper<_Tp, true> 01470 { typedef _Tp& type; }; 01471 01472 /// add_lvalue_reference 01473 template<typename _Tp> 01474 struct add_lvalue_reference 01475 : public __add_lvalue_reference_helper<_Tp> 01476 { }; 01477 01478 template<typename _Tp, bool = __is_referenceable<_Tp>::value> 01479 struct __add_rvalue_reference_helper 01480 { typedef _Tp type; }; 01481 01482 template<typename _Tp> 01483 struct __add_rvalue_reference_helper<_Tp, true> 01484 { typedef _Tp&& type; }; 01485 01486 /// add_rvalue_reference 01487 template<typename _Tp> 01488 struct add_rvalue_reference 01489 : public __add_rvalue_reference_helper<_Tp> 01490 { }; 01491 01492 #if __cplusplus > 201103L 01493 /// Alias template for remove_reference 01494 template<typename _Tp> 01495 using remove_reference_t = typename remove_reference<_Tp>::type; 01496 01497 /// Alias template for add_lvalue_reference 01498 template<typename _Tp> 01499 using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; 01500 01501 /// Alias template for add_rvalue_reference 01502 template<typename _Tp> 01503 using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; 01504 #endif 01505 01506 // Sign modifications. 01507 01508 // Utility for constructing identically cv-qualified types. 01509 template<typename _Unqualified, bool _IsConst, bool _IsVol> 01510 struct __cv_selector; 01511 01512 template<typename _Unqualified> 01513 struct __cv_selector<_Unqualified, false, false> 01514 { typedef _Unqualified __type; }; 01515 01516 template<typename _Unqualified> 01517 struct __cv_selector<_Unqualified, false, true> 01518 { typedef volatile _Unqualified __type; }; 01519 01520 template<typename _Unqualified> 01521 struct __cv_selector<_Unqualified, true, false> 01522 { typedef const _Unqualified __type; }; 01523 01524 template<typename _Unqualified> 01525 struct __cv_selector<_Unqualified, true, true> 01526 { typedef const volatile _Unqualified __type; }; 01527 01528 template<typename _Qualified, typename _Unqualified, 01529 bool _IsConst = is_const<_Qualified>::value, 01530 bool _IsVol = is_volatile<_Qualified>::value> 01531 class __match_cv_qualifiers 01532 { 01533 typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; 01534 01535 public: 01536 typedef typename __match::__type __type; 01537 }; 01538 01539 // Utility for finding the unsigned versions of signed integral types. 01540 template<typename _Tp> 01541 struct __make_unsigned 01542 { typedef _Tp __type; }; 01543 01544 template<> 01545 struct __make_unsigned<char> 01546 { typedef unsigned char __type; }; 01547 01548 template<> 01549 struct __make_unsigned<signed char> 01550 { typedef unsigned char __type; }; 01551 01552 template<> 01553 struct __make_unsigned<short> 01554 { typedef unsigned short __type; }; 01555 01556 template<> 01557 struct __make_unsigned<int> 01558 { typedef unsigned int __type; }; 01559 01560 template<> 01561 struct __make_unsigned<long> 01562 { typedef unsigned long __type; }; 01563 01564 template<> 01565 struct __make_unsigned<long long> 01566 { typedef unsigned long long __type; }; 01567 01568 #if defined(__GLIBCXX_TYPE_INT_N_0) 01569 template<> 01570 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> 01571 { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; 01572 #endif 01573 #if defined(__GLIBCXX_TYPE_INT_N_1) 01574 template<> 01575 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> 01576 { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; 01577 #endif 01578 #if defined(__GLIBCXX_TYPE_INT_N_2) 01579 template<> 01580 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> 01581 { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; 01582 #endif 01583 #if defined(__GLIBCXX_TYPE_INT_N_3) 01584 template<> 01585 struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> 01586 { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; 01587 #endif 01588 01589 // Select between integral and enum: not possible to be both. 01590 template<typename _Tp, 01591 bool _IsInt = is_integral<_Tp>::value, 01592 bool _IsEnum = is_enum<_Tp>::value> 01593 class __make_unsigned_selector; 01594 01595 template<typename _Tp> 01596 class __make_unsigned_selector<_Tp, true, false> 01597 { 01598 typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt; 01599 typedef typename __unsignedt::__type __unsigned_type; 01600 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; 01601 01602 public: 01603 typedef typename __cv_unsigned::__type __type; 01604 }; 01605 01606 template<typename _Tp> 01607 class __make_unsigned_selector<_Tp, false, true> 01608 { 01609 // With -fshort-enums, an enum may be as small as a char. 01610 typedef unsigned char __smallest; 01611 static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest); 01612 static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short); 01613 static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int); 01614 static const bool __b3 = sizeof(_Tp) <= sizeof(unsigned long); 01615 typedef conditional<__b3, unsigned long, unsigned long long> __cond3; 01616 typedef typename __cond3::type __cond3_type; 01617 typedef conditional<__b2, unsigned int, __cond3_type> __cond2; 01618 typedef typename __cond2::type __cond2_type; 01619 typedef conditional<__b1, unsigned short, __cond2_type> __cond1; 01620 typedef typename __cond1::type __cond1_type; 01621 01622 typedef typename conditional<__b0, __smallest, __cond1_type>::type 01623 __unsigned_type; 01624 typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; 01625 01626 public: 01627 typedef typename __cv_unsigned::__type __type; 01628 }; 01629 01630 // Given an integral/enum type, return the corresponding unsigned 01631 // integer type. 01632 // Primary template. 01633 /// make_unsigned 01634 template<typename _Tp> 01635 struct make_unsigned 01636 { typedef typename __make_unsigned_selector<_Tp>::__type type; }; 01637 01638 // Integral, but don't define. 01639 template<> 01640 struct make_unsigned<bool>; 01641 01642 01643 // Utility for finding the signed versions of unsigned integral types. 01644 template<typename _Tp> 01645 struct __make_signed 01646 { typedef _Tp __type; }; 01647 01648 template<> 01649 struct __make_signed<char> 01650 { typedef signed char __type; }; 01651 01652 template<> 01653 struct __make_signed<unsigned char> 01654 { typedef signed char __type; }; 01655 01656 template<> 01657 struct __make_signed<unsigned short> 01658 { typedef signed short __type; }; 01659 01660 template<> 01661 struct __make_signed<unsigned int> 01662 { typedef signed int __type; }; 01663 01664 template<> 01665 struct __make_signed<unsigned long> 01666 { typedef signed long __type; }; 01667 01668 template<> 01669 struct __make_signed<unsigned long long> 01670 { typedef signed long long __type; }; 01671 01672 #if defined(__GLIBCXX_TYPE_INT_N_0) 01673 template<> 01674 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> 01675 { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; 01676 #endif 01677 #if defined(__GLIBCXX_TYPE_INT_N_1) 01678 template<> 01679 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> 01680 { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; 01681 #endif 01682 #if defined(__GLIBCXX_TYPE_INT_N_2) 01683 template<> 01684 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> 01685 { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; 01686 #endif 01687 #if defined(__GLIBCXX_TYPE_INT_N_3) 01688 template<> 01689 struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> 01690 { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; 01691 #endif 01692 01693 // Select between integral and enum: not possible to be both. 01694 template<typename _Tp, 01695 bool _IsInt = is_integral<_Tp>::value, 01696 bool _IsEnum = is_enum<_Tp>::value> 01697 class __make_signed_selector; 01698 01699 template<typename _Tp> 01700 class __make_signed_selector<_Tp, true, false> 01701 { 01702 typedef __make_signed<typename remove_cv<_Tp>::type> __signedt; 01703 typedef typename __signedt::__type __signed_type; 01704 typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed; 01705 01706 public: 01707 typedef typename __cv_signed::__type __type; 01708 }; 01709 01710 template<typename _Tp> 01711 class __make_signed_selector<_Tp, false, true> 01712 { 01713 typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; 01714 01715 public: 01716 typedef typename __make_signed_selector<__unsigned_type>::__type __type; 01717 }; 01718 01719 // Given an integral/enum type, return the corresponding signed 01720 // integer type. 01721 // Primary template. 01722 /// make_signed 01723 template<typename _Tp> 01724 struct make_signed 01725 { typedef typename __make_signed_selector<_Tp>::__type type; }; 01726 01727 // Integral, but don't define. 01728 template<> 01729 struct make_signed<bool>; 01730 01731 #if __cplusplus > 201103L 01732 /// Alias template for make_signed 01733 template<typename _Tp> 01734 using make_signed_t = typename make_signed<_Tp>::type; 01735 01736 /// Alias template for make_unsigned 01737 template<typename _Tp> 01738 using make_unsigned_t = typename make_unsigned<_Tp>::type; 01739 #endif 01740 01741 // Array modifications. 01742 01743 /// remove_extent 01744 template<typename _Tp> 01745 struct remove_extent 01746 { typedef _Tp type; }; 01747 01748 template<typename _Tp, std::size_t _Size> 01749 struct remove_extent<_Tp[_Size]> 01750 { typedef _Tp type; }; 01751 01752 template<typename _Tp> 01753 struct remove_extent<_Tp[]> 01754 { typedef _Tp type; }; 01755 01756 /// remove_all_extents 01757 template<typename _Tp> 01758 struct remove_all_extents 01759 { typedef _Tp type; }; 01760 01761 template<typename _Tp, std::size_t _Size> 01762 struct remove_all_extents<_Tp[_Size]> 01763 { typedef typename remove_all_extents<_Tp>::type type; }; 01764 01765 template<typename _Tp> 01766 struct remove_all_extents<_Tp[]> 01767 { typedef typename remove_all_extents<_Tp>::type type; }; 01768 01769 #if __cplusplus > 201103L 01770 /// Alias template for remove_extent 01771 template<typename _Tp> 01772 using remove_extent_t = typename remove_extent<_Tp>::type; 01773 01774 /// Alias template for remove_all_extents 01775 template<typename _Tp> 01776 using remove_all_extents_t = typename remove_all_extents<_Tp>::type; 01777 #endif 01778 01779 // Pointer modifications. 01780 01781 template<typename _Tp, typename> 01782 struct __remove_pointer_helper 01783 { typedef _Tp type; }; 01784 01785 template<typename _Tp, typename _Up> 01786 struct __remove_pointer_helper<_Tp, _Up*> 01787 { typedef _Up type; }; 01788 01789 /// remove_pointer 01790 template<typename _Tp> 01791 struct remove_pointer 01792 : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> 01793 { }; 01794 01795 /// add_pointer 01796 template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, 01797 is_void<_Tp>>::value> 01798 struct __add_pointer_helper 01799 { typedef _Tp type; }; 01800 01801 template<typename _Tp> 01802 struct __add_pointer_helper<_Tp, true> 01803 { typedef typename remove_reference<_Tp>::type* type; }; 01804 01805 template<typename _Tp> 01806 struct add_pointer 01807 : public __add_pointer_helper<_Tp> 01808 { }; 01809 01810 #if __cplusplus > 201103L 01811 /// Alias template for remove_pointer 01812 template<typename _Tp> 01813 using remove_pointer_t = typename remove_pointer<_Tp>::type; 01814 01815 /// Alias template for add_pointer 01816 template<typename _Tp> 01817 using add_pointer_t = typename add_pointer<_Tp>::type; 01818 #endif 01819 01820 template<std::size_t _Len> 01821 struct __aligned_storage_msa 01822 { 01823 union __type 01824 { 01825 unsigned char __data[_Len]; 01826 struct __attribute__((__aligned__)) { } __align; 01827 }; 01828 }; 01829 01830 /** 01831 * @brief Alignment type. 01832 * 01833 * The value of _Align is a default-alignment which shall be the 01834 * most stringent alignment requirement for any C++ object type 01835 * whose size is no greater than _Len (3.9). The member typedef 01836 * type shall be a POD type suitable for use as uninitialized 01837 * storage for any object whose size is at most _Len and whose 01838 * alignment is a divisor of _Align. 01839 */ 01840 template<std::size_t _Len, std::size_t _Align = 01841 __alignof__(typename __aligned_storage_msa<_Len>::__type)> 01842 struct aligned_storage 01843 { 01844 union type 01845 { 01846 unsigned char __data[_Len]; 01847 struct __attribute__((__aligned__((_Align)))) { } __align; 01848 }; 01849 }; 01850 01851 template <typename... _Types> 01852 struct __strictest_alignment 01853 { 01854 static const size_t _S_alignment = 0; 01855 static const size_t _S_size = 0; 01856 }; 01857 01858 template <typename _Tp, typename... _Types> 01859 struct __strictest_alignment<_Tp, _Types...> 01860 { 01861 static const size_t _S_alignment = 01862 alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment 01863 ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; 01864 static const size_t _S_size = 01865 sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size 01866 ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; 01867 }; 01868 01869 /** 01870 * @brief Provide aligned storage for types. 01871 * 01872 * [meta.trans.other] 01873 * 01874 * Provides aligned storage for any of the provided types of at 01875 * least size _Len. 01876 * 01877 * @see aligned_storage 01878 */ 01879 template <size_t _Len, typename... _Types> 01880 struct aligned_union 01881 { 01882 private: 01883 static_assert(sizeof...(_Types) != 0, "At least one type is required"); 01884 01885 using __strictest = __strictest_alignment<_Types...>; 01886 static const size_t _S_len = _Len > __strictest::_S_size 01887 ? _Len : __strictest::_S_size; 01888 public: 01889 /// The value of the strictest alignment of _Types. 01890 static const size_t alignment_value = __strictest::_S_alignment; 01891 /// The storage. 01892 typedef typename aligned_storage<_S_len, alignment_value>::type type; 01893 }; 01894 01895 template <size_t _Len, typename... _Types> 01896 const size_t aligned_union<_Len, _Types...>::alignment_value; 01897 01898 // Decay trait for arrays and functions, used for perfect forwarding 01899 // in make_pair, make_tuple, etc. 01900 template<typename _Up, 01901 bool _IsArray = is_array<_Up>::value, 01902 bool _IsFunction = is_function<_Up>::value> 01903 struct __decay_selector; 01904 01905 // NB: DR 705. 01906 template<typename _Up> 01907 struct __decay_selector<_Up, false, false> 01908 { typedef typename remove_cv<_Up>::type __type; }; 01909 01910 template<typename _Up> 01911 struct __decay_selector<_Up, true, false> 01912 { typedef typename remove_extent<_Up>::type* __type; }; 01913 01914 template<typename _Up> 01915 struct __decay_selector<_Up, false, true> 01916 { typedef typename add_pointer<_Up>::type __type; }; 01917 01918 /// decay 01919 template<typename _Tp> 01920 class decay 01921 { 01922 typedef typename remove_reference<_Tp>::type __remove_type; 01923 01924 public: 01925 typedef typename __decay_selector<__remove_type>::__type type; 01926 }; 01927 01928 template<typename _Tp> 01929 class reference_wrapper; 01930 01931 // Helper which adds a reference to a type when given a reference_wrapper 01932 template<typename _Tp> 01933 struct __strip_reference_wrapper 01934 { 01935 typedef _Tp __type; 01936 }; 01937 01938 template<typename _Tp> 01939 struct __strip_reference_wrapper<reference_wrapper<_Tp> > 01940 { 01941 typedef _Tp& __type; 01942 }; 01943 01944 template<typename _Tp> 01945 struct __decay_and_strip 01946 { 01947 typedef typename __strip_reference_wrapper< 01948 typename decay<_Tp>::type>::__type __type; 01949 }; 01950 01951 01952 // Primary template. 01953 /// Define a member typedef @c type only if a boolean constant is true. 01954 template<bool, typename _Tp = void> 01955 struct enable_if 01956 { }; 01957 01958 // Partial specialization for true. 01959 template<typename _Tp> 01960 struct enable_if<true, _Tp> 01961 { typedef _Tp type; }; 01962 01963 template<typename... _Cond> 01964 using _Require = typename enable_if<__and_<_Cond...>::value>::type; 01965 01966 // Primary template. 01967 /// Define a member typedef @c type to one of two argument types. 01968 template<bool _Cond, typename _Iftrue, typename _Iffalse> 01969 struct conditional 01970 { typedef _Iftrue type; }; 01971 01972 // Partial specialization for false. 01973 template<typename _Iftrue, typename _Iffalse> 01974 struct conditional<false, _Iftrue, _Iffalse> 01975 { typedef _Iffalse type; }; 01976 01977 /// common_type 01978 template<typename... _Tp> 01979 struct common_type; 01980 01981 // Sfinae-friendly common_type implementation: 01982 01983 struct __do_common_type_impl 01984 { 01985 template<typename _Tp, typename _Up> 01986 static __success_type<typename decay<decltype 01987 (true ? std::declval<_Tp>() 01988 : std::declval<_Up>())>::type> _S_test(int); 01989 01990 template<typename, typename> 01991 static __failure_type _S_test(...); 01992 }; 01993 01994 template<typename _Tp, typename _Up> 01995 struct __common_type_impl 01996 : private __do_common_type_impl 01997 { 01998 typedef decltype(_S_test<_Tp, _Up>(0)) type; 01999 }; 02000 02001 struct __do_member_type_wrapper 02002 { 02003 template<typename _Tp> 02004 static __success_type<typename _Tp::type> _S_test(int); 02005 02006 template<typename> 02007 static __failure_type _S_test(...); 02008 }; 02009 02010 template<typename _Tp> 02011 struct __member_type_wrapper 02012 : private __do_member_type_wrapper 02013 { 02014 typedef decltype(_S_test<_Tp>(0)) type; 02015 }; 02016 02017 template<typename _CTp, typename... _Args> 02018 struct __expanded_common_type_wrapper 02019 { 02020 typedef common_type<typename _CTp::type, _Args...> type; 02021 }; 02022 02023 template<typename... _Args> 02024 struct __expanded_common_type_wrapper<__failure_type, _Args...> 02025 { typedef __failure_type type; }; 02026 02027 template<typename _Tp> 02028 struct common_type<_Tp> 02029 { typedef typename decay<_Tp>::type type; }; 02030 02031 template<typename _Tp, typename _Up> 02032 struct common_type<_Tp, _Up> 02033 : public __common_type_impl<_Tp, _Up>::type 02034 { }; 02035 02036 template<typename _Tp, typename _Up, typename... _Vp> 02037 struct common_type<_Tp, _Up, _Vp...> 02038 : public __expanded_common_type_wrapper<typename __member_type_wrapper< 02039 common_type<_Tp, _Up>>::type, _Vp...>::type 02040 { }; 02041 02042 /// The underlying type of an enum. 02043 template<typename _Tp> 02044 struct underlying_type 02045 { 02046 typedef __underlying_type(_Tp) type; 02047 }; 02048 02049 template<typename _Tp> 02050 struct __declval_protector 02051 { 02052 static const bool __stop = false; 02053 }; 02054 02055 template<typename _Tp> 02056 auto declval() noexcept -> decltype(__declval<_Tp>(0)) 02057 { 02058 static_assert(__declval_protector<_Tp>::__stop, 02059 "declval() must not be used!"); 02060 return __declval<_Tp>(0); 02061 } 02062 02063 // wchar_t, char16_t and char32_t are integral types but are neither 02064 // signed integer types nor unsigned integer types, so must be 02065 // transformed to the integer type with the smallest rank that has the 02066 // same size and signedness. 02067 // Use the partial specialization for enumeration types to do that, 02068 // which means these explicit specializations must be defined after 02069 // std::conditional has been defined. 02070 02071 #if defined(_GLIBCXX_USE_WCHAR_T) 02072 template<> 02073 struct __make_unsigned<wchar_t> 02074 { 02075 using __type 02076 = typename __make_unsigned_selector<wchar_t, false, true>::__type; 02077 }; 02078 02079 template<> 02080 struct __make_signed<wchar_t> 02081 { 02082 using __type 02083 = typename __make_signed_selector<wchar_t, false, true>::__type; 02084 }; 02085 #endif 02086 02087 template<> 02088 struct __make_unsigned<char16_t> 02089 { 02090 using __type 02091 = typename __make_unsigned_selector<char16_t, false, true>::__type; 02092 }; 02093 02094 template<> 02095 struct __make_signed<char16_t> 02096 { 02097 using __type 02098 = typename __make_signed_selector<char16_t, false, true>::__type; 02099 }; 02100 02101 template<> 02102 struct __make_unsigned<char32_t> 02103 { 02104 using __type 02105 = typename __make_unsigned_selector<char32_t, false, true>::__type; 02106 }; 02107 02108 template<> 02109 struct __make_signed<char32_t> 02110 { 02111 using __type 02112 = typename __make_signed_selector<char32_t, false, true>::__type; 02113 }; 02114 02115 02116 /// result_of 02117 template<typename _Signature> 02118 class result_of; 02119 02120 // Sfinae-friendly result_of implementation: 02121 02122 #define __cpp_lib_result_of_sfinae 201210 02123 02124 struct __invoke_memfun_ref { }; 02125 struct __invoke_memfun_deref { }; 02126 struct __invoke_memobj_ref { }; 02127 struct __invoke_memobj_deref { }; 02128 struct __invoke_other { }; 02129 02130 // Associate a tag type with a specialization of __success_type. 02131 template<typename _Tp, typename _Tag> 02132 struct __result_of_success : __success_type<_Tp> 02133 { using __invoke_type = _Tag; }; 02134 02135 // [func.require] paragraph 1 bullet 1: 02136 struct __result_of_memfun_ref_impl 02137 { 02138 template<typename _Fp, typename _Tp1, typename... _Args> 02139 static __result_of_success<decltype( 02140 (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) 02141 ), __invoke_memfun_ref> _S_test(int); 02142 02143 template<typename...> 02144 static __failure_type _S_test(...); 02145 }; 02146 02147 template<typename _MemPtr, typename _Arg, typename... _Args> 02148 struct __result_of_memfun_ref 02149 : private __result_of_memfun_ref_impl 02150 { 02151 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; 02152 }; 02153 02154 // [func.require] paragraph 1 bullet 2: 02155 struct __result_of_memfun_deref_impl 02156 { 02157 template<typename _Fp, typename _Tp1, typename... _Args> 02158 static __result_of_success<decltype( 02159 ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) 02160 ), __invoke_memfun_deref> _S_test(int); 02161 02162 template<typename...> 02163 static __failure_type _S_test(...); 02164 }; 02165 02166 template<typename _MemPtr, typename _Arg, typename... _Args> 02167 struct __result_of_memfun_deref 02168 : private __result_of_memfun_deref_impl 02169 { 02170 typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; 02171 }; 02172 02173 // [func.require] paragraph 1 bullet 3: 02174 struct __result_of_memobj_ref_impl 02175 { 02176 template<typename _Fp, typename _Tp1> 02177 static __result_of_success<decltype( 02178 std::declval<_Tp1>().*std::declval<_Fp>() 02179 ), __invoke_memobj_ref> _S_test(int); 02180 02181 template<typename, typename> 02182 static __failure_type _S_test(...); 02183 }; 02184 02185 template<typename _MemPtr, typename _Arg> 02186 struct __result_of_memobj_ref 02187 : private __result_of_memobj_ref_impl 02188 { 02189 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; 02190 }; 02191 02192 // [func.require] paragraph 1 bullet 4: 02193 struct __result_of_memobj_deref_impl 02194 { 02195 template<typename _Fp, typename _Tp1> 02196 static __result_of_success<decltype( 02197 (*std::declval<_Tp1>()).*std::declval<_Fp>() 02198 ), __invoke_memobj_deref> _S_test(int); 02199 02200 template<typename, typename> 02201 static __failure_type _S_test(...); 02202 }; 02203 02204 template<typename _MemPtr, typename _Arg> 02205 struct __result_of_memobj_deref 02206 : private __result_of_memobj_deref_impl 02207 { 02208 typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; 02209 }; 02210 02211 template<typename _MemPtr, typename _Arg> 02212 struct __result_of_memobj; 02213 02214 template<typename _Res, typename _Class, typename _Arg> 02215 struct __result_of_memobj<_Res _Class::*, _Arg> 02216 { 02217 typedef typename remove_cv<typename remove_reference< 02218 _Arg>::type>::type _Argval; 02219 typedef _Res _Class::* _MemPtr; 02220 typedef typename conditional<__or_<is_same<_Argval, _Class>, 02221 is_base_of<_Class, _Argval>>::value, 02222 __result_of_memobj_ref<_MemPtr, _Arg>, 02223 __result_of_memobj_deref<_MemPtr, _Arg> 02224 >::type::type type; 02225 }; 02226 02227 template<typename _MemPtr, typename _Arg, typename... _Args> 02228 struct __result_of_memfun; 02229 02230 template<typename _Res, typename _Class, typename _Arg, typename... _Args> 02231 struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> 02232 { 02233 typedef typename remove_cv<typename remove_reference< 02234 _Arg>::type>::type _Argval; 02235 typedef _Res _Class::* _MemPtr; 02236 typedef typename conditional<__or_<is_same<_Argval, _Class>, 02237 is_base_of<_Class, _Argval>>::value, 02238 __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, 02239 __result_of_memfun_deref<_MemPtr, _Arg, _Args...> 02240 >::type::type type; 02241 }; 02242 02243 // _GLIBCXX_RESOLVE_LIB_DEFECTS 02244 // 2219. INVOKE-ing a pointer to member with a reference_wrapper 02245 // as the object expression 02246 02247 // Used by result_of, invoke etc. to unwrap a reference_wrapper. 02248 template<typename _Tp, typename _Up = typename decay<_Tp>::type> 02249 struct __inv_unwrap 02250 { 02251 using type = _Tp; 02252 }; 02253 02254 template<typename _Tp, typename _Up> 02255 struct __inv_unwrap<_Tp, reference_wrapper<_Up>> 02256 { 02257 using type = _Up&; 02258 }; 02259 02260 template<bool, bool, typename _Functor, typename... _ArgTypes> 02261 struct __result_of_impl 02262 { 02263 typedef __failure_type type; 02264 }; 02265 02266 template<typename _MemPtr, typename _Arg> 02267 struct __result_of_impl<true, false, _MemPtr, _Arg> 02268 : public __result_of_memobj<typename decay<_MemPtr>::type, 02269 typename __inv_unwrap<_Arg>::type> 02270 { }; 02271 02272 template<typename _MemPtr, typename _Arg, typename... _Args> 02273 struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> 02274 : public __result_of_memfun<typename decay<_MemPtr>::type, 02275 typename __inv_unwrap<_Arg>::type, _Args...> 02276 { }; 02277 02278 // [func.require] paragraph 1 bullet 5: 02279 struct __result_of_other_impl 02280 { 02281 template<typename _Fn, typename... _Args> 02282 static __result_of_success<decltype( 02283 std::declval<_Fn>()(std::declval<_Args>()...) 02284 ), __invoke_other> _S_test(int); 02285 02286 template<typename...> 02287 static __failure_type _S_test(...); 02288 }; 02289 02290 template<typename _Functor, typename... _ArgTypes> 02291 struct __result_of_impl<false, false, _Functor, _ArgTypes...> 02292 : private __result_of_other_impl 02293 { 02294 typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; 02295 }; 02296 02297 // __invoke_result (std::invoke_result for C++11) 02298 template<typename _Functor, typename... _ArgTypes> 02299 struct __invoke_result 02300 : public __result_of_impl< 02301 is_member_object_pointer< 02302 typename remove_reference<_Functor>::type 02303 >::value, 02304 is_member_function_pointer< 02305 typename remove_reference<_Functor>::type 02306 >::value, 02307 _Functor, _ArgTypes... 02308 >::type 02309 { }; 02310 02311 template<typename _Functor, typename... _ArgTypes> 02312 struct result_of<_Functor(_ArgTypes...)> 02313 : public __invoke_result<_Functor, _ArgTypes...> 02314 { }; 02315 02316 #if __cplusplus > 201103L 02317 /// Alias template for aligned_storage 02318 template<size_t _Len, size_t _Align = 02319 __alignof__(typename __aligned_storage_msa<_Len>::__type)> 02320 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; 02321 02322 template <size_t _Len, typename... _Types> 02323 using aligned_union_t = typename aligned_union<_Len, _Types...>::type; 02324 02325 /// Alias template for decay 02326 template<typename _Tp> 02327 using decay_t = typename decay<_Tp>::type; 02328 02329 /// Alias template for enable_if 02330 template<bool _Cond, typename _Tp = void> 02331 using enable_if_t = typename enable_if<_Cond, _Tp>::type; 02332 02333 /// Alias template for conditional 02334 template<bool _Cond, typename _Iftrue, typename _Iffalse> 02335 using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; 02336 02337 /// Alias template for common_type 02338 template<typename... _Tp> 02339 using common_type_t = typename common_type<_Tp...>::type; 02340 02341 /// Alias template for underlying_type 02342 template<typename _Tp> 02343 using underlying_type_t = typename underlying_type<_Tp>::type; 02344 02345 /// Alias template for result_of 02346 template<typename _Tp> 02347 using result_of_t = typename result_of<_Tp>::type; 02348 #endif 02349 02350 template<typename...> using __void_t = void; 02351 02352 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 02353 #define __cpp_lib_void_t 201411 02354 /// A metafunction that always yields void, used for detecting valid types. 02355 template<typename...> using void_t = void; 02356 #endif 02357 02358 /// Implementation of the detection idiom (negative case). 02359 template<typename _Default, typename _AlwaysVoid, 02360 template<typename...> class _Op, typename... _Args> 02361 struct __detector 02362 { 02363 using value_t = false_type; 02364 using type = _Default; 02365 }; 02366 02367 /// Implementation of the detection idiom (positive case). 02368 template<typename _Default, template<typename...> class _Op, 02369 typename... _Args> 02370 struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> 02371 { 02372 using value_t = true_type; 02373 using type = _Op<_Args...>; 02374 }; 02375 02376 // Detect whether _Op<_Args...> is a valid type, use _Default if not. 02377 template<typename _Default, template<typename...> class _Op, 02378 typename... _Args> 02379 using __detected_or = __detector<_Default, void, _Op, _Args...>; 02380 02381 // _Op<_Args...> if that is a valid type, otherwise _Default. 02382 template<typename _Default, template<typename...> class _Op, 02383 typename... _Args> 02384 using __detected_or_t 02385 = typename __detected_or<_Default, _Op, _Args...>::type; 02386 02387 /// @} group metaprogramming 02388 02389 /** 02390 * Use SFINAE to determine if the type _Tp has a publicly-accessible 02391 * member type _NTYPE. 02392 */ 02393 #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ 02394 template<typename _Tp, typename = __void_t<>> \ 02395 struct __has_##_NTYPE \ 02396 : false_type \ 02397 { }; \ 02398 template<typename _Tp> \ 02399 struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ 02400 : true_type \ 02401 { }; 02402 02403 template <typename _Tp> 02404 struct __is_swappable; 02405 02406 template <typename _Tp> 02407 struct __is_nothrow_swappable; 02408 02409 template<typename... _Elements> 02410 class tuple; 02411 02412 template<typename> 02413 struct __is_tuple_like_impl : false_type 02414 { }; 02415 02416 template<typename... _Tps> 02417 struct __is_tuple_like_impl<tuple<_Tps...>> : true_type 02418 { }; 02419 02420 // Internal type trait that allows us to sfinae-protect tuple_cat. 02421 template<typename _Tp> 02422 struct __is_tuple_like 02423 : public __is_tuple_like_impl<typename remove_cv< 02424 typename remove_reference<_Tp>::type>::type>::type 02425 { }; 02426 02427 template<typename _Tp> 02428 inline 02429 typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>, 02430 is_move_constructible<_Tp>, 02431 is_move_assignable<_Tp>>::value>::type 02432 swap(_Tp&, _Tp&) 02433 noexcept(__and_<is_nothrow_move_constructible<_Tp>, 02434 is_nothrow_move_assignable<_Tp>>::value); 02435 02436 template<typename _Tp, size_t _Nm> 02437 inline 02438 typename enable_if<__is_swappable<_Tp>::value>::type 02439 swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) 02440 noexcept(__is_nothrow_swappable<_Tp>::value); 02441 02442 namespace __swappable_details { 02443 using std::swap; 02444 02445 struct __do_is_swappable_impl 02446 { 02447 template<typename _Tp, typename 02448 = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> 02449 static true_type __test(int); 02450 02451 template<typename> 02452 static false_type __test(...); 02453 }; 02454 02455 struct __do_is_nothrow_swappable_impl 02456 { 02457 template<typename _Tp> 02458 static __bool_constant< 02459 noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) 02460 > __test(int); 02461 02462 template<typename> 02463 static false_type __test(...); 02464 }; 02465 02466 } // namespace __swappable_details 02467 02468 template<typename _Tp> 02469 struct __is_swappable_impl 02470 : public __swappable_details::__do_is_swappable_impl 02471 { 02472 typedef decltype(__test<_Tp>(0)) type; 02473 }; 02474 02475 template<typename _Tp> 02476 struct __is_nothrow_swappable_impl 02477 : public __swappable_details::__do_is_nothrow_swappable_impl 02478 { 02479 typedef decltype(__test<_Tp>(0)) type; 02480 }; 02481 02482 template<typename _Tp> 02483 struct __is_swappable 02484 : public __is_swappable_impl<_Tp>::type 02485 { }; 02486 02487 template<typename _Tp> 02488 struct __is_nothrow_swappable 02489 : public __is_nothrow_swappable_impl<_Tp>::type 02490 { }; 02491 02492 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 02493 #define __cpp_lib_is_swappable 201603 02494 /// Metafunctions used for detecting swappable types: p0185r1 02495 02496 /// is_swappable 02497 template<typename _Tp> 02498 struct is_swappable 02499 : public __is_swappable_impl<_Tp>::type 02500 { }; 02501 02502 /// is_nothrow_swappable 02503 template<typename _Tp> 02504 struct is_nothrow_swappable 02505 : public __is_nothrow_swappable_impl<_Tp>::type 02506 { }; 02507 02508 #if __cplusplus >= 201402L 02509 /// is_swappable_v 02510 template<typename _Tp> 02511 _GLIBCXX17_INLINE constexpr bool is_swappable_v = 02512 is_swappable<_Tp>::value; 02513 02514 /// is_nothrow_swappable_v 02515 template<typename _Tp> 02516 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = 02517 is_nothrow_swappable<_Tp>::value; 02518 #endif // __cplusplus >= 201402L 02519 02520 namespace __swappable_with_details { 02521 using std::swap; 02522 02523 struct __do_is_swappable_with_impl 02524 { 02525 template<typename _Tp, typename _Up, typename 02526 = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), 02527 typename 02528 = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> 02529 static true_type __test(int); 02530 02531 template<typename, typename> 02532 static false_type __test(...); 02533 }; 02534 02535 struct __do_is_nothrow_swappable_with_impl 02536 { 02537 template<typename _Tp, typename _Up> 02538 static __bool_constant< 02539 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) 02540 && 02541 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) 02542 > __test(int); 02543 02544 template<typename, typename> 02545 static false_type __test(...); 02546 }; 02547 02548 } // namespace __swappable_with_details 02549 02550 template<typename _Tp, typename _Up> 02551 struct __is_swappable_with_impl 02552 : public __swappable_with_details::__do_is_swappable_with_impl 02553 { 02554 typedef decltype(__test<_Tp, _Up>(0)) type; 02555 }; 02556 02557 // Optimization for the homogenous lvalue case, not required: 02558 template<typename _Tp> 02559 struct __is_swappable_with_impl<_Tp&, _Tp&> 02560 : public __swappable_details::__do_is_swappable_impl 02561 { 02562 typedef decltype(__test<_Tp&>(0)) type; 02563 }; 02564 02565 template<typename _Tp, typename _Up> 02566 struct __is_nothrow_swappable_with_impl 02567 : public __swappable_with_details::__do_is_nothrow_swappable_with_impl 02568 { 02569 typedef decltype(__test<_Tp, _Up>(0)) type; 02570 }; 02571 02572 // Optimization for the homogenous lvalue case, not required: 02573 template<typename _Tp> 02574 struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> 02575 : public __swappable_details::__do_is_nothrow_swappable_impl 02576 { 02577 typedef decltype(__test<_Tp&>(0)) type; 02578 }; 02579 02580 /// is_swappable_with 02581 template<typename _Tp, typename _Up> 02582 struct is_swappable_with 02583 : public __is_swappable_with_impl<_Tp, _Up>::type 02584 { }; 02585 02586 /// is_nothrow_swappable_with 02587 template<typename _Tp, typename _Up> 02588 struct is_nothrow_swappable_with 02589 : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type 02590 { }; 02591 02592 #if __cplusplus >= 201402L 02593 /// is_swappable_with_v 02594 template<typename _Tp, typename _Up> 02595 _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = 02596 is_swappable_with<_Tp, _Up>::value; 02597 02598 /// is_nothrow_swappable_with_v 02599 template<typename _Tp, typename _Up> 02600 _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = 02601 is_nothrow_swappable_with<_Tp, _Up>::value; 02602 #endif // __cplusplus >= 201402L 02603 02604 #endif// c++1z or gnu++11 02605 02606 // __is_invocable (std::is_invocable for C++11) 02607 02608 template<typename _Result, typename _Ret, typename = void> 02609 struct __is_invocable_impl : false_type { }; 02610 02611 template<typename _Result, typename _Ret> 02612 struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>> 02613 : __or_<is_void<_Ret>, is_convertible<typename _Result::type, _Ret>>::type 02614 { }; 02615 02616 template<typename _Fn, typename... _ArgTypes> 02617 struct __is_invocable 02618 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type 02619 { }; 02620 02621 template<typename _Fn, typename _Tp, typename... _Args> 02622 constexpr bool __call_is_nt(__invoke_memfun_ref) 02623 { 02624 using _Up = typename __inv_unwrap<_Tp>::type; 02625 return noexcept((std::declval<_Up>().*std::declval<_Fn>())( 02626 std::declval<_Args>()...)); 02627 } 02628 02629 template<typename _Fn, typename _Tp, typename... _Args> 02630 constexpr bool __call_is_nt(__invoke_memfun_deref) 02631 { 02632 return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( 02633 std::declval<_Args>()...)); 02634 } 02635 02636 template<typename _Fn, typename _Tp> 02637 constexpr bool __call_is_nt(__invoke_memobj_ref) 02638 { 02639 using _Up = typename __inv_unwrap<_Tp>::type; 02640 return noexcept(std::declval<_Up>().*std::declval<_Fn>()); 02641 } 02642 02643 template<typename _Fn, typename _Tp> 02644 constexpr bool __call_is_nt(__invoke_memobj_deref) 02645 { 02646 return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); 02647 } 02648 02649 template<typename _Fn, typename... _Args> 02650 constexpr bool __call_is_nt(__invoke_other) 02651 { 02652 return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); 02653 } 02654 02655 template<typename _Result, typename _Fn, typename... _Args> 02656 struct __call_is_nothrow 02657 : __bool_constant< 02658 std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) 02659 > 02660 { }; 02661 02662 template<typename _Fn, typename... _Args> 02663 using __call_is_nothrow_ 02664 = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; 02665 02666 // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) 02667 template<typename _Fn, typename... _Args> 02668 struct __is_nothrow_invocable 02669 : __and_<__is_invocable<_Fn, _Args...>, 02670 __call_is_nothrow_<_Fn, _Args...>>::type 02671 { }; 02672 02673 struct __nonesuch { 02674 __nonesuch() = delete; 02675 ~__nonesuch() = delete; 02676 __nonesuch(__nonesuch const&) = delete; 02677 void operator=(__nonesuch const&) = delete; 02678 }; 02679 02680 #if __cplusplus >= 201703L 02681 # define __cpp_lib_is_invocable 201703 02682 02683 /// std::invoke_result 02684 template<typename _Functor, typename... _ArgTypes> 02685 struct invoke_result 02686 : public __invoke_result<_Functor, _ArgTypes...> 02687 { }; 02688 02689 /// std::invoke_result_t 02690 template<typename _Fn, typename... _Args> 02691 using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; 02692 02693 /// std::is_invocable 02694 template<typename _Fn, typename... _ArgTypes> 02695 struct is_invocable 02696 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type 02697 { }; 02698 02699 /// std::is_invocable_r 02700 template<typename _Ret, typename _Fn, typename... _ArgTypes> 02701 struct is_invocable_r 02702 : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type 02703 { }; 02704 02705 /// std::is_nothrow_invocable 02706 template<typename _Fn, typename... _ArgTypes> 02707 struct is_nothrow_invocable 02708 : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, 02709 __call_is_nothrow_<_Fn, _ArgTypes...>>::type 02710 { }; 02711 02712 template<typename _Result, typename _Ret, typename = void> 02713 struct __is_nt_invocable_impl : false_type { }; 02714 02715 template<typename _Result, typename _Ret> 02716 struct __is_nt_invocable_impl<_Result, _Ret, 02717 __void_t<typename _Result::type>> 02718 : __or_<is_void<_Ret>, 02719 __and_<is_convertible<typename _Result::type, _Ret>, 02720 is_nothrow_constructible<_Ret, typename _Result::type>>> 02721 { }; 02722 02723 /// std::is_nothrow_invocable_r 02724 template<typename _Ret, typename _Fn, typename... _ArgTypes> 02725 struct is_nothrow_invocable_r 02726 : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, 02727 __call_is_nothrow_<_Fn, _ArgTypes...>>::type 02728 { }; 02729 02730 /// std::is_invocable_v 02731 template<typename _Fn, typename... _Args> 02732 inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; 02733 02734 /// std::is_nothrow_invocable_v 02735 template<typename _Fn, typename... _Args> 02736 inline constexpr bool is_nothrow_invocable_v 02737 = is_nothrow_invocable<_Fn, _Args...>::value; 02738 02739 /// std::is_invocable_r_v 02740 template<typename _Fn, typename... _Args> 02741 inline constexpr bool is_invocable_r_v 02742 = is_invocable_r<_Fn, _Args...>::value; 02743 02744 /// std::is_nothrow_invocable_r_v 02745 template<typename _Fn, typename... _Args> 02746 inline constexpr bool is_nothrow_invocable_r_v 02747 = is_nothrow_invocable_r<_Fn, _Args...>::value; 02748 #endif // C++17 02749 02750 #if __cplusplus >= 201703L 02751 # define __cpp_lib_type_trait_variable_templates 201510L 02752 template <typename _Tp> 02753 inline constexpr bool is_void_v = is_void<_Tp>::value; 02754 template <typename _Tp> 02755 inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; 02756 template <typename _Tp> 02757 inline constexpr bool is_integral_v = is_integral<_Tp>::value; 02758 template <typename _Tp> 02759 inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; 02760 template <typename _Tp> 02761 inline constexpr bool is_array_v = is_array<_Tp>::value; 02762 template <typename _Tp> 02763 inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; 02764 template <typename _Tp> 02765 inline constexpr bool is_lvalue_reference_v = 02766 is_lvalue_reference<_Tp>::value; 02767 template <typename _Tp> 02768 inline constexpr bool is_rvalue_reference_v = 02769 is_rvalue_reference<_Tp>::value; 02770 template <typename _Tp> 02771 inline constexpr bool is_member_object_pointer_v = 02772 is_member_object_pointer<_Tp>::value; 02773 template <typename _Tp> 02774 inline constexpr bool is_member_function_pointer_v = 02775 is_member_function_pointer<_Tp>::value; 02776 template <typename _Tp> 02777 inline constexpr bool is_enum_v = is_enum<_Tp>::value; 02778 template <typename _Tp> 02779 inline constexpr bool is_union_v = is_union<_Tp>::value; 02780 template <typename _Tp> 02781 inline constexpr bool is_class_v = is_class<_Tp>::value; 02782 template <typename _Tp> 02783 inline constexpr bool is_function_v = is_function<_Tp>::value; 02784 template <typename _Tp> 02785 inline constexpr bool is_reference_v = is_reference<_Tp>::value; 02786 template <typename _Tp> 02787 inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; 02788 template <typename _Tp> 02789 inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; 02790 template <typename _Tp> 02791 inline constexpr bool is_object_v = is_object<_Tp>::value; 02792 template <typename _Tp> 02793 inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; 02794 template <typename _Tp> 02795 inline constexpr bool is_compound_v = is_compound<_Tp>::value; 02796 template <typename _Tp> 02797 inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; 02798 template <typename _Tp> 02799 inline constexpr bool is_const_v = is_const<_Tp>::value; 02800 template <typename _Tp> 02801 inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; 02802 template <typename _Tp> 02803 inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; 02804 template <typename _Tp> 02805 inline constexpr bool is_trivially_copyable_v = 02806 is_trivially_copyable<_Tp>::value; 02807 template <typename _Tp> 02808 inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; 02809 template <typename _Tp> 02810 inline constexpr bool is_pod_v = is_pod<_Tp>::value; 02811 template <typename _Tp> 02812 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; 02813 template <typename _Tp> 02814 inline constexpr bool is_empty_v = is_empty<_Tp>::value; 02815 template <typename _Tp> 02816 inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; 02817 template <typename _Tp> 02818 inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; 02819 template <typename _Tp> 02820 inline constexpr bool is_final_v = is_final<_Tp>::value; 02821 template <typename _Tp> 02822 inline constexpr bool is_signed_v = is_signed<_Tp>::value; 02823 template <typename _Tp> 02824 inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; 02825 template <typename _Tp, typename... _Args> 02826 inline constexpr bool is_constructible_v = 02827 is_constructible<_Tp, _Args...>::value; 02828 template <typename _Tp> 02829 inline constexpr bool is_default_constructible_v = 02830 is_default_constructible<_Tp>::value; 02831 template <typename _Tp> 02832 inline constexpr bool is_copy_constructible_v = 02833 is_copy_constructible<_Tp>::value; 02834 template <typename _Tp> 02835 inline constexpr bool is_move_constructible_v = 02836 is_move_constructible<_Tp>::value; 02837 template <typename _Tp, typename _Up> 02838 inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; 02839 template <typename _Tp> 02840 inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; 02841 template <typename _Tp> 02842 inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; 02843 template <typename _Tp> 02844 inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; 02845 template <typename _Tp, typename... _Args> 02846 inline constexpr bool is_trivially_constructible_v = 02847 is_trivially_constructible<_Tp, _Args...>::value; 02848 template <typename _Tp> 02849 inline constexpr bool is_trivially_default_constructible_v = 02850 is_trivially_default_constructible<_Tp>::value; 02851 template <typename _Tp> 02852 inline constexpr bool is_trivially_copy_constructible_v = 02853 is_trivially_copy_constructible<_Tp>::value; 02854 template <typename _Tp> 02855 inline constexpr bool is_trivially_move_constructible_v = 02856 is_trivially_move_constructible<_Tp>::value; 02857 template <typename _Tp, typename _Up> 02858 inline constexpr bool is_trivially_assignable_v = 02859 is_trivially_assignable<_Tp, _Up>::value; 02860 template <typename _Tp> 02861 inline constexpr bool is_trivially_copy_assignable_v = 02862 is_trivially_copy_assignable<_Tp>::value; 02863 template <typename _Tp> 02864 inline constexpr bool is_trivially_move_assignable_v = 02865 is_trivially_move_assignable<_Tp>::value; 02866 template <typename _Tp> 02867 inline constexpr bool is_trivially_destructible_v = 02868 is_trivially_destructible<_Tp>::value; 02869 template <typename _Tp, typename... _Args> 02870 inline constexpr bool is_nothrow_constructible_v = 02871 is_nothrow_constructible<_Tp, _Args...>::value; 02872 template <typename _Tp> 02873 inline constexpr bool is_nothrow_default_constructible_v = 02874 is_nothrow_default_constructible<_Tp>::value; 02875 template <typename _Tp> 02876 inline constexpr bool is_nothrow_copy_constructible_v = 02877 is_nothrow_copy_constructible<_Tp>::value; 02878 template <typename _Tp> 02879 inline constexpr bool is_nothrow_move_constructible_v = 02880 is_nothrow_move_constructible<_Tp>::value; 02881 template <typename _Tp, typename _Up> 02882 inline constexpr bool is_nothrow_assignable_v = 02883 is_nothrow_assignable<_Tp, _Up>::value; 02884 template <typename _Tp> 02885 inline constexpr bool is_nothrow_copy_assignable_v = 02886 is_nothrow_copy_assignable<_Tp>::value; 02887 template <typename _Tp> 02888 inline constexpr bool is_nothrow_move_assignable_v = 02889 is_nothrow_move_assignable<_Tp>::value; 02890 template <typename _Tp> 02891 inline constexpr bool is_nothrow_destructible_v = 02892 is_nothrow_destructible<_Tp>::value; 02893 template <typename _Tp> 02894 inline constexpr bool has_virtual_destructor_v = 02895 has_virtual_destructor<_Tp>::value; 02896 template <typename _Tp> 02897 inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; 02898 template <typename _Tp> 02899 inline constexpr size_t rank_v = rank<_Tp>::value; 02900 template <typename _Tp, unsigned _Idx = 0> 02901 inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; 02902 template <typename _Tp, typename _Up> 02903 inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; 02904 template <typename _Base, typename _Derived> 02905 inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; 02906 template <typename _From, typename _To> 02907 inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; 02908 02909 #if __GNUC__ >= 7 02910 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 02911 #elif defined(__is_identifier) 02912 // For non-GNU compilers: 02913 # if ! __is_identifier(__has_unique_object_representations) 02914 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 02915 # endif 02916 #endif 02917 02918 #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 02919 # define __cpp_lib_has_unique_object_representations 201606 02920 /// has_unique_object_representations 02921 template<typename _Tp> 02922 struct has_unique_object_representations 02923 : bool_constant<__has_unique_object_representations( 02924 remove_cv_t<remove_all_extents_t<_Tp>> 02925 )> 02926 { }; 02927 02928 template<typename _Tp> 02929 inline constexpr bool has_unique_object_representations_v 02930 = has_unique_object_representations<_Tp>::value; 02931 #endif 02932 #undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 02933 02934 #if __GNUC__ >= 7 02935 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 02936 #elif defined(__is_identifier) 02937 // For non-GNU compilers: 02938 # if ! __is_identifier(__is_aggregate) 02939 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 02940 # endif 02941 #endif 02942 02943 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 02944 #define __cpp_lib_is_aggregate 201703 02945 /// is_aggregate 02946 template<typename _Tp> 02947 struct is_aggregate 02948 : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { }; 02949 02950 /// is_aggregate_v 02951 template<typename _Tp> 02952 inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; 02953 #endif 02954 #undef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 02955 02956 #endif // C++17 02957 02958 #if __cplusplus > 201703L 02959 /// Byte order 02960 enum class endian 02961 { 02962 little = __ORDER_LITTLE_ENDIAN__, 02963 big = __ORDER_BIG_ENDIAN__, 02964 native = __BYTE_ORDER__ 02965 }; 02966 #endif // C++2a 02967 02968 _GLIBCXX_END_NAMESPACE_VERSION 02969 } // namespace std 02970 02971 #endif // C++11 02972 02973 #endif // _GLIBCXX_TYPE_TRAITS