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