libstdc++
type_traits
Go to the documentation of this file.
00001 // Variable Templates For Type Traits -*- C++ -*-
00002 
00003 // Copyright (C) 2014-2018 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 experimental/type_traits
00026  *  This is a TS C++ Library header.
00027  */
00028 
00029 //
00030 // N3932 Variable Templates For Type Traits (Revision 1)
00031 //
00032 
00033 #ifndef _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS
00034 #define _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS 1
00035 
00036 #pragma GCC system_header
00037 
00038 #if __cplusplus >= 201402L
00039 
00040 #include <type_traits>
00041 #include <experimental/bits/lfts_config.h>
00042 
00043 namespace std _GLIBCXX_VISIBILITY(default)
00044 {
00045 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00046 
00047 namespace experimental
00048 {
00049 inline namespace fundamentals_v1
00050 {
00051 #define __cpp_lib_experimental_type_trait_variable_templates 201402
00052 
00053 // See C++14 §20.10.4.1, primary type categories
00054 template <typename _Tp>
00055   constexpr bool is_void_v = is_void<_Tp>::value;
00056 template <typename _Tp>
00057   constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
00058 template <typename _Tp>
00059   constexpr bool is_integral_v = is_integral<_Tp>::value;
00060 template <typename _Tp>
00061   constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
00062 template <typename _Tp>
00063   constexpr bool is_array_v = is_array<_Tp>::value;
00064 template <typename _Tp>
00065   constexpr bool is_pointer_v = is_pointer<_Tp>::value;
00066 template <typename _Tp>
00067   constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
00068 template <typename _Tp>
00069   constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
00070 template <typename _Tp>
00071   constexpr bool is_member_object_pointer_v =
00072     is_member_object_pointer<_Tp>::value;
00073 template <typename _Tp>
00074   constexpr bool is_member_function_pointer_v =
00075     is_member_function_pointer<_Tp>::value;
00076 template <typename _Tp>
00077   constexpr bool is_enum_v = is_enum<_Tp>::value;
00078 template <typename _Tp>
00079   constexpr bool is_union_v = is_union<_Tp>::value;
00080 template <typename _Tp>
00081   constexpr bool is_class_v = is_class<_Tp>::value;
00082 template <typename _Tp>
00083   constexpr bool is_function_v = is_function<_Tp>::value;
00084 
00085 // See C++14 §20.10.4.2, composite type categories
00086 template <typename _Tp>
00087   constexpr bool is_reference_v = is_reference<_Tp>::value;
00088 template <typename _Tp>
00089   constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
00090 template <typename _Tp>
00091   constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
00092 template <typename _Tp>
00093   constexpr bool is_object_v = is_object<_Tp>::value;
00094 template <typename _Tp>
00095   constexpr bool is_scalar_v = is_scalar<_Tp>::value;
00096 template <typename _Tp>
00097   constexpr bool is_compound_v = is_compound<_Tp>::value;
00098 template <typename _Tp>
00099  constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
00100 
00101 // See C++14 §20.10.4.3, type properties
00102 template <typename _Tp>
00103   constexpr bool is_const_v = is_const<_Tp>::value;
00104 template <typename _Tp>
00105   constexpr bool is_volatile_v = is_volatile<_Tp>::value;
00106 template <typename _Tp>
00107   constexpr bool is_trivial_v = is_trivial<_Tp>::value;
00108 template <typename _Tp>
00109   constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
00110 template <typename _Tp>
00111   constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
00112 template <typename _Tp>
00113   constexpr bool is_pod_v = is_pod<_Tp>::value;
00114 template <typename _Tp>
00115   constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
00116 template <typename _Tp>
00117   constexpr bool is_empty_v = is_empty<_Tp>::value;
00118 template <typename _Tp>
00119   constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
00120 template <typename _Tp>
00121   constexpr bool is_abstract_v = is_abstract<_Tp>::value;
00122 template <typename _Tp>
00123   constexpr bool is_final_v = is_final<_Tp>::value;
00124 template <typename _Tp>
00125   constexpr bool is_signed_v = is_signed<_Tp>::value;
00126 template <typename _Tp>
00127   constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
00128 template <typename _Tp, typename... _Args>
00129   constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
00130 template <typename _Tp>
00131   constexpr bool is_default_constructible_v =
00132     is_default_constructible<_Tp>::value;
00133 template <typename _Tp>
00134   constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
00135 template <typename _Tp>
00136   constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
00137 template <typename _Tp, typename _Up>
00138   constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
00139 template <typename _Tp>
00140   constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
00141 template <typename _Tp>
00142   constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
00143 template <typename _Tp>
00144   constexpr bool is_destructible_v = is_destructible<_Tp>::value;
00145 template <typename _Tp, typename... _Args>
00146   constexpr bool is_trivially_constructible_v =
00147     is_trivially_constructible<_Tp, _Args...>::value;
00148 template <typename _Tp>
00149   constexpr bool is_trivially_default_constructible_v =
00150     is_trivially_default_constructible<_Tp>::value;
00151 template <typename _Tp>
00152   constexpr bool is_trivially_copy_constructible_v =
00153     is_trivially_copy_constructible<_Tp>::value;
00154 template <typename _Tp>
00155   constexpr bool is_trivially_move_constructible_v =
00156     is_trivially_move_constructible<_Tp>::value;
00157 template <typename _Tp, typename _Up>
00158   constexpr bool is_trivially_assignable_v =
00159     is_trivially_assignable<_Tp, _Up>::value;
00160 template <typename _Tp>
00161   constexpr bool is_trivially_copy_assignable_v =
00162     is_trivially_copy_assignable<_Tp>::value;
00163 template <typename _Tp>
00164   constexpr bool is_trivially_move_assignable_v =
00165     is_trivially_move_assignable<_Tp>::value;
00166 template <typename _Tp>
00167   constexpr bool is_trivially_destructible_v =
00168     is_trivially_destructible<_Tp>::value;
00169 template <typename _Tp, typename... _Args>
00170   constexpr bool is_nothrow_constructible_v =
00171     is_nothrow_constructible<_Tp, _Args...>::value;
00172 template <typename _Tp>
00173   constexpr bool is_nothrow_default_constructible_v =
00174     is_nothrow_default_constructible<_Tp>::value;
00175 template <typename _Tp>
00176   constexpr bool is_nothrow_copy_constructible_v =
00177     is_nothrow_copy_constructible<_Tp>::value;
00178 template <typename _Tp>
00179   constexpr bool is_nothrow_move_constructible_v =
00180     is_nothrow_move_constructible<_Tp>::value;
00181 template <typename _Tp, typename _Up>
00182   constexpr bool is_nothrow_assignable_v =
00183     is_nothrow_assignable<_Tp, _Up>::value;
00184 template <typename _Tp>
00185   constexpr bool is_nothrow_copy_assignable_v =
00186     is_nothrow_copy_assignable<_Tp>::value;
00187 template <typename _Tp>
00188   constexpr bool is_nothrow_move_assignable_v =
00189     is_nothrow_move_assignable<_Tp>::value;
00190 template <typename _Tp>
00191   constexpr bool is_nothrow_destructible_v =
00192     is_nothrow_destructible<_Tp>::value;
00193 template <typename _Tp>
00194   constexpr bool has_virtual_destructor_v =
00195     has_virtual_destructor<_Tp>::value;
00196 
00197 // See C++14 §20.10.5, type property queries
00198 template <typename _Tp>
00199   constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
00200 template <typename _Tp>
00201   constexpr size_t rank_v = rank<_Tp>::value;
00202 template <typename _Tp, unsigned _Idx = 0>
00203   constexpr size_t extent_v = extent<_Tp, _Idx>::value;
00204 
00205 // See C++14 §20.10.6, type relations
00206 template <typename _Tp, typename _Up>
00207   constexpr bool is_same_v = is_same<_Tp, _Up>::value;
00208 template <typename _Base, typename _Derived>
00209   constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
00210 template <typename _From, typename _To>
00211   constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
00212 
00213 
00214   // 3.3.2, Other type transformations
00215   // invocation_type (still unimplemented)
00216   // raw_invocation_type (still unimplemented)
00217   // invocation_type_t (still unimplemented)
00218   // raw_invocation_type_t (still unimplemented)
00219 } // namespace fundamentals_v1
00220 
00221 inline namespace fundamentals_v2
00222 {
00223 #define __cpp_lib_experimental_detect 201505
00224 
00225 // [meta.detect]
00226 
00227 template<typename...> using void_t = void;
00228 
00229 struct nonesuch
00230 {
00231   nonesuch() = delete;
00232   ~nonesuch() = delete;
00233   nonesuch(nonesuch const&) = delete;
00234   void operator=(nonesuch const&) = delete;
00235 };
00236 
00237 template<template<typename...> class _Op, typename... _Args>
00238   using is_detected
00239     = typename std::__detector<nonesuch, void, _Op, _Args...>::value_t;
00240 
00241 template<template<typename...> class _Op, typename... _Args>
00242   constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
00243 
00244 template<template<typename...> class _Op, typename... _Args>
00245   using detected_t
00246     = typename std::__detector<nonesuch, void, _Op, _Args...>::type;
00247 
00248 template<typename _Default, template<typename...> class _Op, typename... _Args>
00249   using detected_or = std::__detected_or<_Default, _Op, _Args...>;
00250 
00251 template<typename _Default, template<typename...> class _Op, typename... _Args>
00252   using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type;
00253 
00254 template<typename Expected, template<typename...> class _Op, typename... _Args>
00255   using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>;
00256 
00257 template<typename Expected, template<typename...> class _Op, typename... _Args>
00258   constexpr bool is_detected_exact_v
00259     = is_detected_exact<Expected, _Op, _Args...>::value;
00260 
00261 template<typename _To, template<typename...> class _Op, typename... _Args>
00262   using is_detected_convertible
00263     = is_convertible<detected_t<_Op, _Args...>, _To>;
00264 
00265 template<typename _To, template<typename...> class _Op, typename... _Args>
00266   constexpr bool is_detected_convertible_v
00267     = is_detected_convertible<_To, _Op, _Args...>::value;
00268 
00269 #define __cpp_lib_experimental_logical_traits 201511
00270 
00271 template<typename... _Bn>
00272   struct conjunction
00273   : __and_<_Bn...>
00274   { };
00275 
00276 template<typename... _Bn>
00277   struct disjunction
00278   : __or_<_Bn...>
00279   { };
00280 
00281 template<typename _Pp>
00282   struct negation
00283   : __not_<_Pp>
00284   { };
00285 
00286 template<typename... _Bn>
00287   constexpr bool conjunction_v
00288     = conjunction<_Bn...>::value;
00289 
00290 template<typename... _Bn>
00291   constexpr bool disjunction_v
00292     = disjunction<_Bn...>::value;
00293 
00294 template<typename _Pp>
00295   constexpr bool negation_v
00296     = negation<_Pp>::value;
00297 } // namespace fundamentals_v2
00298 } // namespace experimental
00299 
00300 _GLIBCXX_END_NAMESPACE_VERSION
00301 } // namespace std
00302 
00303 #endif // __cplusplus <= 201103L
00304 
00305 #endif // _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS