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