libstdc++
|
00001 // Variable Templates For Type Traits -*- C++ -*- 00002 00003 // Copyright (C) 2014-2016 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file 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 <= 201103L 00039 # include <bits/c++14_warning.h> 00040 #else 00041 00042 #include <type_traits> 00043 00044 00045 namespace std _GLIBCXX_VISIBILITY(default) 00046 { 00047 namespace experimental 00048 { 00049 inline namespace fundamentals_v1 00050 { 00051 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00052 00053 #define __cpp_lib_experimental_type_trait_variable_templates 201402 00054 00055 // See C++14 §20.10.4.1, primary type categories 00056 template <typename _Tp> 00057 constexpr bool is_void_v = is_void<_Tp>::value; 00058 template <typename _Tp> 00059 constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; 00060 template <typename _Tp> 00061 constexpr bool is_integral_v = is_integral<_Tp>::value; 00062 template <typename _Tp> 00063 constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; 00064 template <typename _Tp> 00065 constexpr bool is_array_v = is_array<_Tp>::value; 00066 template <typename _Tp> 00067 constexpr bool is_pointer_v = is_pointer<_Tp>::value; 00068 template <typename _Tp> 00069 constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; 00070 template <typename _Tp> 00071 constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; 00072 template <typename _Tp> 00073 constexpr bool is_member_object_pointer_v = 00074 is_member_object_pointer<_Tp>::value; 00075 template <typename _Tp> 00076 constexpr bool is_member_function_pointer_v = 00077 is_member_function_pointer<_Tp>::value; 00078 template <typename _Tp> 00079 constexpr bool is_enum_v = is_enum<_Tp>::value; 00080 template <typename _Tp> 00081 constexpr bool is_union_v = is_union<_Tp>::value; 00082 template <typename _Tp> 00083 constexpr bool is_class_v = is_class<_Tp>::value; 00084 template <typename _Tp> 00085 constexpr bool is_function_v = is_function<_Tp>::value; 00086 00087 // See C++14 §20.10.4.2, composite type categories 00088 template <typename _Tp> 00089 constexpr bool is_reference_v = is_reference<_Tp>::value; 00090 template <typename _Tp> 00091 constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; 00092 template <typename _Tp> 00093 constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; 00094 template <typename _Tp> 00095 constexpr bool is_object_v = is_object<_Tp>::value; 00096 template <typename _Tp> 00097 constexpr bool is_scalar_v = is_scalar<_Tp>::value; 00098 template <typename _Tp> 00099 constexpr bool is_compound_v = is_compound<_Tp>::value; 00100 template <typename _Tp> 00101 constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; 00102 00103 // See C++14 §20.10.4.3, type properties 00104 template <typename _Tp> 00105 constexpr bool is_const_v = is_const<_Tp>::value; 00106 template <typename _Tp> 00107 constexpr bool is_volatile_v = is_volatile<_Tp>::value; 00108 template <typename _Tp> 00109 constexpr bool is_trivial_v = is_trivial<_Tp>::value; 00110 template <typename _Tp> 00111 constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; 00112 template <typename _Tp> 00113 constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; 00114 template <typename _Tp> 00115 constexpr bool is_pod_v = is_pod<_Tp>::value; 00116 template <typename _Tp> 00117 constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; 00118 template <typename _Tp> 00119 constexpr bool is_empty_v = is_empty<_Tp>::value; 00120 template <typename _Tp> 00121 constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; 00122 template <typename _Tp> 00123 constexpr bool is_abstract_v = is_abstract<_Tp>::value; 00124 template <typename _Tp> 00125 constexpr bool is_final_v = is_final<_Tp>::value; 00126 template <typename _Tp> 00127 constexpr bool is_signed_v = is_signed<_Tp>::value; 00128 template <typename _Tp> 00129 constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; 00130 template <typename _Tp, typename... _Args> 00131 constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; 00132 template <typename _Tp> 00133 constexpr bool is_default_constructible_v = 00134 is_default_constructible<_Tp>::value; 00135 template <typename _Tp> 00136 constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; 00137 template <typename _Tp> 00138 constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; 00139 template <typename _Tp, typename _Up> 00140 constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; 00141 template <typename _Tp> 00142 constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; 00143 template <typename _Tp> 00144 constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; 00145 template <typename _Tp> 00146 constexpr bool is_destructible_v = is_destructible<_Tp>::value; 00147 template <typename _Tp, typename... _Args> 00148 constexpr bool is_trivially_constructible_v = 00149 is_trivially_constructible<_Tp, _Args...>::value; 00150 template <typename _Tp> 00151 constexpr bool is_trivially_default_constructible_v = 00152 is_trivially_default_constructible<_Tp>::value; 00153 template <typename _Tp> 00154 constexpr bool is_trivially_copy_constructible_v = 00155 is_trivially_copy_constructible<_Tp>::value; 00156 template <typename _Tp> 00157 constexpr bool is_trivially_move_constructible_v = 00158 is_trivially_move_constructible<_Tp>::value; 00159 template <typename _Tp, typename _Up> 00160 constexpr bool is_trivially_assignable_v = 00161 is_trivially_assignable<_Tp, _Up>::value; 00162 template <typename _Tp> 00163 constexpr bool is_trivially_copy_assignable_v = 00164 is_trivially_copy_assignable<_Tp>::value; 00165 template <typename _Tp> 00166 constexpr bool is_trivially_move_assignable_v = 00167 is_trivially_move_assignable<_Tp>::value; 00168 template <typename _Tp> 00169 constexpr bool is_trivially_destructible_v = 00170 is_trivially_destructible<_Tp>::value; 00171 template <typename _Tp, typename... _Args> 00172 constexpr bool is_nothrow_constructible_v = 00173 is_nothrow_constructible<_Tp, _Args...>::value; 00174 template <typename _Tp> 00175 constexpr bool is_nothrow_default_constructible_v = 00176 is_nothrow_default_constructible<_Tp>::value; 00177 template <typename _Tp> 00178 constexpr bool is_nothrow_copy_constructible_v = 00179 is_nothrow_copy_constructible<_Tp>::value; 00180 template <typename _Tp> 00181 constexpr bool is_nothrow_move_constructible_v = 00182 is_nothrow_move_constructible<_Tp>::value; 00183 template <typename _Tp, typename _Up> 00184 constexpr bool is_nothrow_assignable_v = 00185 is_nothrow_assignable<_Tp, _Up>::value; 00186 template <typename _Tp> 00187 constexpr bool is_nothrow_copy_assignable_v = 00188 is_nothrow_copy_assignable<_Tp>::value; 00189 template <typename _Tp> 00190 constexpr bool is_nothrow_move_assignable_v = 00191 is_nothrow_move_assignable<_Tp>::value; 00192 template <typename _Tp> 00193 constexpr bool is_nothrow_destructible_v = 00194 is_nothrow_destructible<_Tp>::value; 00195 template <typename _Tp> 00196 constexpr bool has_virtual_destructor_v = 00197 has_virtual_destructor<_Tp>::value; 00198 00199 // See C++14 §20.10.5, type property queries 00200 template <typename _Tp> 00201 constexpr size_t alignment_of_v = alignment_of<_Tp>::value; 00202 template <typename _Tp> 00203 constexpr size_t rank_v = rank<_Tp>::value; 00204 template <typename _Tp, unsigned _Idx = 0> 00205 constexpr size_t extent_v = extent<_Tp, _Idx>::value; 00206 00207 // See C++14 §20.10.6, type relations 00208 template <typename _Tp, typename _Up> 00209 constexpr bool is_same_v = is_same<_Tp, _Up>::value; 00210 template <typename _Base, typename _Derived> 00211 constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; 00212 template <typename _From, typename _To> 00213 constexpr bool is_convertible_v = is_convertible<_From, _To>::value; 00214 00215 00216 // 3.3.2, Other type transformations 00217 // invocation_type (still unimplemented) 00218 // raw_invocation_type (still unimplemented) 00219 // invocation_type_t (still unimplemented) 00220 // raw_invocation_type_t (still unimplemented) 00221 _GLIBCXX_END_NAMESPACE_VERSION 00222 } // namespace fundamentals_v1 00223 00224 inline namespace fundamentals_v2 00225 { 00226 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00227 00228 #define __cpp_lib_experimental_detect 201505 00229 00230 // [meta.detect] 00231 00232 template<typename...> using void_t = void; 00233 00234 struct nonesuch 00235 { 00236 nonesuch() = delete; 00237 ~nonesuch() = delete; 00238 nonesuch(nonesuch const&) = delete; 00239 void operator=(nonesuch const&) = delete; 00240 }; 00241 00242 template<template<typename...> class _Op, typename... _Args> 00243 using is_detected 00244 = typename std::__detector<nonesuch, void, _Op, _Args...>::value_t; 00245 00246 template<template<typename...> class _Op, typename... _Args> 00247 constexpr bool is_detected_v = is_detected<_Op, _Args...>::value; 00248 00249 template<template<typename...> class _Op, typename... _Args> 00250 using detected_t 00251 = typename std::__detector<nonesuch, void, _Op, _Args...>::type; 00252 00253 template<typename _Default, template<typename...> class _Op, typename... _Args> 00254 using detected_or = std::__detected_or<_Default, _Op, _Args...>; 00255 00256 template<typename _Default, template<typename...> class _Op, typename... _Args> 00257 using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; 00258 00259 template<typename Expected, template<typename...> class _Op, typename... _Args> 00260 using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>; 00261 00262 template<typename Expected, template<typename...> class _Op, typename... _Args> 00263 constexpr bool is_detected_exact_v 00264 = is_detected_exact<Expected, _Op, _Args...>::value; 00265 00266 template<typename _To, template<typename...> class _Op, typename... _Args> 00267 using is_detected_convertible 00268 = is_convertible<detected_t<_Op, _Args...>, _To>; 00269 00270 template<typename _To, template<typename...> class _Op, typename... _Args> 00271 constexpr bool is_detected_convertible_v 00272 = is_detected_convertible<_To, _Op, _Args...>::value; 00273 00274 #define __cpp_lib_experimental_logical_traits 201511 00275 00276 template<typename... _Bn> 00277 struct conjunction 00278 : __and_<_Bn...> 00279 { }; 00280 00281 template<typename... _Bn> 00282 struct disjunction 00283 : __or_<_Bn...> 00284 { }; 00285 00286 template<typename _Pp> 00287 struct negation 00288 : __not_<_Pp> 00289 { }; 00290 00291 template<typename... _Bn> 00292 constexpr bool conjunction_v 00293 = conjunction<_Bn...>::value; 00294 00295 template<typename... _Bn> 00296 constexpr bool disjunction_v 00297 = disjunction<_Bn...>::value; 00298 00299 template<typename _Pp> 00300 constexpr bool negation_v 00301 = negation<_Pp>::value; 00302 00303 _GLIBCXX_END_NAMESPACE_VERSION 00304 } // namespace fundamentals_v2 00305 } // namespace experimental 00306 } // namespace std 00307 00308 #endif // __cplusplus <= 201103L 00309 00310 #endif // _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS