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