libstdc++
experimental/type_traits
Go to the documentation of this file.
1 // Variable Templates For Type Traits -*- C++ -*-
2 
3 // Copyright (C) 2014-2020 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /** @file experimental/type_traits
26  * This is a TS C++ Library header.
27  * @ingroup libfund-ts
28  */
29 
30 //
31 // N3932 Variable Templates For Type Traits (Revision 1)
32 //
33 
34 #ifndef _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS
35 #define _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS 1
36 
37 #pragma GCC system_header
38 
39 #if __cplusplus >= 201402L
40 
41 #include <type_traits>
42 #include <experimental/bits/lfts_config.h>
43 
44 namespace std _GLIBCXX_VISIBILITY(default)
45 {
46 _GLIBCXX_BEGIN_NAMESPACE_VERSION
47 
48 namespace experimental
49 {
50 inline namespace fundamentals_v1
51 {
52 #define __cpp_lib_experimental_type_trait_variable_templates 201402
53 
54 // See C++14 20.10.4.1, primary type categories
55 template <typename _Tp>
56  constexpr bool is_void_v = is_void<_Tp>::value;
57 template <typename _Tp>
58  constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
59 template <typename _Tp>
60  constexpr bool is_integral_v = is_integral<_Tp>::value;
61 template <typename _Tp>
62  constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
63 template <typename _Tp>
64  constexpr bool is_array_v = is_array<_Tp>::value;
65 template <typename _Tp>
66  constexpr bool is_pointer_v = is_pointer<_Tp>::value;
67 template <typename _Tp>
68  constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
69 template <typename _Tp>
70  constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
71 template <typename _Tp>
72  constexpr bool is_member_object_pointer_v =
73  is_member_object_pointer<_Tp>::value;
74 template <typename _Tp>
75  constexpr bool is_member_function_pointer_v =
76  is_member_function_pointer<_Tp>::value;
77 template <typename _Tp>
78  constexpr bool is_enum_v = is_enum<_Tp>::value;
79 template <typename _Tp>
80  constexpr bool is_union_v = is_union<_Tp>::value;
81 template <typename _Tp>
82  constexpr bool is_class_v = is_class<_Tp>::value;
83 template <typename _Tp>
84  constexpr bool is_function_v = is_function<_Tp>::value;
85 
86 // See C++14 20.10.4.2, composite type categories
87 template <typename _Tp>
88  constexpr bool is_reference_v = is_reference<_Tp>::value;
89 template <typename _Tp>
90  constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
91 template <typename _Tp>
92  constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
93 template <typename _Tp>
94  constexpr bool is_object_v = is_object<_Tp>::value;
95 template <typename _Tp>
96  constexpr bool is_scalar_v = is_scalar<_Tp>::value;
97 template <typename _Tp>
98  constexpr bool is_compound_v = is_compound<_Tp>::value;
99 template <typename _Tp>
100  constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
101 
102 // See C++14 20.10.4.3, type properties
103 template <typename _Tp>
104  constexpr bool is_const_v = is_const<_Tp>::value;
105 template <typename _Tp>
106  constexpr bool is_volatile_v = is_volatile<_Tp>::value;
107 template <typename _Tp>
108  constexpr bool is_trivial_v = is_trivial<_Tp>::value;
109 template <typename _Tp>
110  constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
111 template <typename _Tp>
112  constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
113 #pragma GCC diagnostic push
114 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
115 template <typename _Tp>
116  constexpr bool is_pod_v = is_pod<_Tp>::value;
117 template <typename _Tp>
118  constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
119 #pragma GCC diagnostic pop
120 template <typename _Tp>
121  constexpr bool is_empty_v = is_empty<_Tp>::value;
122 template <typename _Tp>
123  constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
124 template <typename _Tp>
125  constexpr bool is_abstract_v = is_abstract<_Tp>::value;
126 template <typename _Tp>
127  constexpr bool is_final_v = is_final<_Tp>::value;
128 template <typename _Tp>
129  constexpr bool is_signed_v = is_signed<_Tp>::value;
130 template <typename _Tp>
131  constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
132 template <typename _Tp, typename... _Args>
133  constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
134 template <typename _Tp>
135  constexpr bool is_default_constructible_v =
136  is_default_constructible<_Tp>::value;
137 template <typename _Tp>
138  constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
139 template <typename _Tp>
140  constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
141 template <typename _Tp, typename _Up>
142  constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
143 template <typename _Tp>
144  constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
145 template <typename _Tp>
146  constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
147 template <typename _Tp>
148  constexpr bool is_destructible_v = is_destructible<_Tp>::value;
149 template <typename _Tp, typename... _Args>
150  constexpr bool is_trivially_constructible_v =
151  is_trivially_constructible<_Tp, _Args...>::value;
152 template <typename _Tp>
153  constexpr bool is_trivially_default_constructible_v =
154  is_trivially_default_constructible<_Tp>::value;
155 template <typename _Tp>
156  constexpr bool is_trivially_copy_constructible_v =
157  is_trivially_copy_constructible<_Tp>::value;
158 template <typename _Tp>
159  constexpr bool is_trivially_move_constructible_v =
160  is_trivially_move_constructible<_Tp>::value;
161 template <typename _Tp, typename _Up>
162  constexpr bool is_trivially_assignable_v =
163  is_trivially_assignable<_Tp, _Up>::value;
164 template <typename _Tp>
165  constexpr bool is_trivially_copy_assignable_v =
166  is_trivially_copy_assignable<_Tp>::value;
167 template <typename _Tp>
168  constexpr bool is_trivially_move_assignable_v =
169  is_trivially_move_assignable<_Tp>::value;
170 template <typename _Tp>
171  constexpr bool is_trivially_destructible_v =
172  is_trivially_destructible<_Tp>::value;
173 template <typename _Tp, typename... _Args>
174  constexpr bool is_nothrow_constructible_v =
175  is_nothrow_constructible<_Tp, _Args...>::value;
176 template <typename _Tp>
177  constexpr bool is_nothrow_default_constructible_v =
178  is_nothrow_default_constructible<_Tp>::value;
179 template <typename _Tp>
180  constexpr bool is_nothrow_copy_constructible_v =
181  is_nothrow_copy_constructible<_Tp>::value;
182 template <typename _Tp>
183  constexpr bool is_nothrow_move_constructible_v =
184  is_nothrow_move_constructible<_Tp>::value;
185 template <typename _Tp, typename _Up>
186  constexpr bool is_nothrow_assignable_v =
187  is_nothrow_assignable<_Tp, _Up>::value;
188 template <typename _Tp>
189  constexpr bool is_nothrow_copy_assignable_v =
190  is_nothrow_copy_assignable<_Tp>::value;
191 template <typename _Tp>
192  constexpr bool is_nothrow_move_assignable_v =
193  is_nothrow_move_assignable<_Tp>::value;
194 template <typename _Tp>
195  constexpr bool is_nothrow_destructible_v =
196  is_nothrow_destructible<_Tp>::value;
197 template <typename _Tp>
198  constexpr bool has_virtual_destructor_v =
199  has_virtual_destructor<_Tp>::value;
200 
201 // See C++14 20.10.5, type property queries
202 template <typename _Tp>
203  constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
204 template <typename _Tp>
205  constexpr size_t rank_v = rank<_Tp>::value;
206 template <typename _Tp, unsigned _Idx = 0>
207  constexpr size_t extent_v = extent<_Tp, _Idx>::value;
208 
209 // See C++14 20.10.6, type relations
210 template <typename _Tp, typename _Up>
211  constexpr bool is_same_v = is_same<_Tp, _Up>::value;
212 template <typename _Base, typename _Derived>
213  constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
214 template <typename _From, typename _To>
215  constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
216 
217 
218  // 3.3.2, Other type transformations
219  // invocation_type (still unimplemented)
220  // raw_invocation_type (still unimplemented)
221  // invocation_type_t (still unimplemented)
222  // raw_invocation_type_t (still unimplemented)
223 } // namespace fundamentals_v1
224 
225 inline namespace fundamentals_v2
226 {
227 #define __cpp_lib_experimental_detect 201505
228 
229 // [meta.detect]
230 
231 template<typename...> using void_t = void;
232 
233 #pragma GCC diagnostic push
234 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
235 struct __nonesuchbase {};
236 struct nonesuch : private __nonesuchbase
237 {
238  ~nonesuch() = delete;
239  nonesuch(nonesuch const&) = delete;
240  void operator=(nonesuch const&) = delete;
241 };
242 #pragma GCC diagnostic pop
243 
244 template<template<typename...> class _Op, typename... _Args>
245  using is_detected
246  = typename std::__detector<nonesuch, void, _Op, _Args...>::value_t;
247 
248 template<template<typename...> class _Op, typename... _Args>
249  constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
250 
251 template<template<typename...> class _Op, typename... _Args>
252  using detected_t
253  = typename std::__detector<nonesuch, void, _Op, _Args...>::type;
254 
255 template<typename _Default, template<typename...> class _Op, typename... _Args>
256  using detected_or = std::__detected_or<_Default, _Op, _Args...>;
257 
258 template<typename _Default, template<typename...> class _Op, typename... _Args>
259  using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type;
260 
261 template<typename _Expected, template<typename...> class _Op, typename... _Args>
262  using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>;
263 
264 template<typename _Expected, template<typename...> class _Op, typename... _Args>
265  constexpr bool is_detected_exact_v
266  = is_detected_exact<_Expected, _Op, _Args...>::value;
267 
268 template<typename _To, template<typename...> class _Op, typename... _Args>
269  using is_detected_convertible
270  = is_convertible<detected_t<_Op, _Args...>, _To>;
271 
272 template<typename _To, template<typename...> class _Op, typename... _Args>
273  constexpr bool is_detected_convertible_v
274  = is_detected_convertible<_To, _Op, _Args...>::value;
275 
276 #define __cpp_lib_experimental_logical_traits 201511
277 
278 template<typename... _Bn>
279  struct conjunction
280  : __and_<_Bn...>
281  { };
282 
283 template<typename... _Bn>
284  struct disjunction
285  : __or_<_Bn...>
286  { };
287 
288 template<typename _Pp>
289  struct negation
290  : __not_<_Pp>
291  { };
292 
293 template<typename... _Bn>
294  constexpr bool conjunction_v
295  = conjunction<_Bn...>::value;
296 
297 template<typename... _Bn>
298  constexpr bool disjunction_v
299  = disjunction<_Bn...>::value;
300 
301 template<typename _Pp>
302  constexpr bool negation_v
303  = negation<_Pp>::value;
304 } // namespace fundamentals_v2
305 } // namespace experimental
306 
307 _GLIBCXX_END_NAMESPACE_VERSION
308 } // namespace std
309 
310 #endif // __cplusplus <= 201103L
311 
312 #endif // _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS