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