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