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