libstdc++
experimental/type_traits
Go to the documentation of this file.
1 // Variable Templates For Type Traits -*- C++ -*-
2 
3 // Copyright (C) 2014-2019 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>
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 template <typename _Tp>
114  constexpr bool is_pod_v = is_pod<_Tp>::value;
115 template <typename _Tp>
116  constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
117 template <typename _Tp>
118  constexpr bool is_empty_v = is_empty<_Tp>::value;
119 template <typename _Tp>
120  constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
121 template <typename _Tp>
122  constexpr bool is_abstract_v = is_abstract<_Tp>::value;
123 template <typename _Tp>
124  constexpr bool is_final_v = is_final<_Tp>::value;
125 template <typename _Tp>
126  constexpr bool is_signed_v = is_signed<_Tp>::value;
127 template <typename _Tp>
128  constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
129 template <typename _Tp, typename... _Args>
130  constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
131 template <typename _Tp>
132  constexpr bool is_default_constructible_v =
133  is_default_constructible<_Tp>::value;
134 template <typename _Tp>
135  constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
136 template <typename _Tp>
137  constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
138 template <typename _Tp, typename _Up>
139  constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
140 template <typename _Tp>
141  constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
142 template <typename _Tp>
143  constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
144 template <typename _Tp>
145  constexpr bool is_destructible_v = is_destructible<_Tp>::value;
146 template <typename _Tp, typename... _Args>
147  constexpr bool is_trivially_constructible_v =
148  is_trivially_constructible<_Tp, _Args...>::value;
149 template <typename _Tp>
150  constexpr bool is_trivially_default_constructible_v =
151  is_trivially_default_constructible<_Tp>::value;
152 template <typename _Tp>
153  constexpr bool is_trivially_copy_constructible_v =
154  is_trivially_copy_constructible<_Tp>::value;
155 template <typename _Tp>
156  constexpr bool is_trivially_move_constructible_v =
157  is_trivially_move_constructible<_Tp>::value;
158 template <typename _Tp, typename _Up>
159  constexpr bool is_trivially_assignable_v =
160  is_trivially_assignable<_Tp, _Up>::value;
161 template <typename _Tp>
162  constexpr bool is_trivially_copy_assignable_v =
163  is_trivially_copy_assignable<_Tp>::value;
164 template <typename _Tp>
165  constexpr bool is_trivially_move_assignable_v =
166  is_trivially_move_assignable<_Tp>::value;
167 template <typename _Tp>
168  constexpr bool is_trivially_destructible_v =
169  is_trivially_destructible<_Tp>::value;
170 template <typename _Tp, typename... _Args>
171  constexpr bool is_nothrow_constructible_v =
172  is_nothrow_constructible<_Tp, _Args...>::value;
173 template <typename _Tp>
174  constexpr bool is_nothrow_default_constructible_v =
175  is_nothrow_default_constructible<_Tp>::value;
176 template <typename _Tp>
177  constexpr bool is_nothrow_copy_constructible_v =
178  is_nothrow_copy_constructible<_Tp>::value;
179 template <typename _Tp>
180  constexpr bool is_nothrow_move_constructible_v =
181  is_nothrow_move_constructible<_Tp>::value;
182 template <typename _Tp, typename _Up>
183  constexpr bool is_nothrow_assignable_v =
184  is_nothrow_assignable<_Tp, _Up>::value;
185 template <typename _Tp>
186  constexpr bool is_nothrow_copy_assignable_v =
187  is_nothrow_copy_assignable<_Tp>::value;
188 template <typename _Tp>
189  constexpr bool is_nothrow_move_assignable_v =
190  is_nothrow_move_assignable<_Tp>::value;
191 template <typename _Tp>
192  constexpr bool is_nothrow_destructible_v =
193  is_nothrow_destructible<_Tp>::value;
194 template <typename _Tp>
195  constexpr bool has_virtual_destructor_v =
196  has_virtual_destructor<_Tp>::value;
197 
198 // See C++14 20.10.5, type property queries
199 template <typename _Tp>
200  constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
201 template <typename _Tp>
202  constexpr size_t rank_v = rank<_Tp>::value;
203 template <typename _Tp, unsigned _Idx = 0>
204  constexpr size_t extent_v = extent<_Tp, _Idx>::value;
205 
206 // See C++14 20.10.6, type relations
207 template <typename _Tp, typename _Up>
208  constexpr bool is_same_v = is_same<_Tp, _Up>::value;
209 template <typename _Base, typename _Derived>
210  constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
211 template <typename _From, typename _To>
212  constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
213 
214 
215  // 3.3.2, Other type transformations
216  // invocation_type (still unimplemented)
217  // raw_invocation_type (still unimplemented)
218  // invocation_type_t (still unimplemented)
219  // raw_invocation_type_t (still unimplemented)
220 } // namespace fundamentals_v1
221 
222 inline namespace fundamentals_v2
223 {
224 #define __cpp_lib_experimental_detect 201505
225 
226 // [meta.detect]
227 
228 template<typename...> using void_t = void;
229 
230 #pragma GCC diagnostic push
231 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
232 struct __nonesuchbase {};
233 struct nonesuch : private __nonesuchbase
234 {
235  ~nonesuch() = delete;
236  nonesuch(nonesuch const&) = delete;
237  void operator=(nonesuch const&) = delete;
238 };
239 #pragma GCC diagnostic pop
240 
241 template<template<typename...> class _Op, typename... _Args>
242  using is_detected
243  = typename std::__detector<nonesuch, void, _Op, _Args...>::value_t;
244 
245 template<template<typename...> class _Op, typename... _Args>
246  constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
247 
248 template<template<typename...> class _Op, typename... _Args>
249  using detected_t
250  = typename std::__detector<nonesuch, void, _Op, _Args...>::type;
251 
252 template<typename _Default, template<typename...> class _Op, typename... _Args>
253  using detected_or = std::__detected_or<_Default, _Op, _Args...>;
254 
255 template<typename _Default, template<typename...> class _Op, typename... _Args>
256  using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type;
257 
258 template<typename _Expected, template<typename...> class _Op, typename... _Args>
259  using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>;
260 
261 template<typename _Expected, template<typename...> class _Op, typename... _Args>
262  constexpr bool is_detected_exact_v
263  = is_detected_exact<_Expected, _Op, _Args...>::value;
264 
265 template<typename _To, template<typename...> class _Op, typename... _Args>
266  using is_detected_convertible
267  = is_convertible<detected_t<_Op, _Args...>, _To>;
268 
269 template<typename _To, template<typename...> class _Op, typename... _Args>
270  constexpr bool is_detected_convertible_v
271  = is_detected_convertible<_To, _Op, _Args...>::value;
272 
273 #define __cpp_lib_experimental_logical_traits 201511
274 
275 template<typename... _Bn>
276  struct conjunction
277  : __and_<_Bn...>
278  { };
279 
280 template<typename... _Bn>
281  struct disjunction
282  : __or_<_Bn...>
283  { };
284 
285 template<typename _Pp>
286  struct negation
287  : __not_<_Pp>
288  { };
289 
290 template<typename... _Bn>
291  constexpr bool conjunction_v
292  = conjunction<_Bn...>::value;
293 
294 template<typename... _Bn>
295  constexpr bool disjunction_v
296  = disjunction<_Bn...>::value;
297 
298 template<typename _Pp>
299  constexpr bool negation_v
300  = negation<_Pp>::value;
301 } // namespace fundamentals_v2
302 } // namespace experimental
303 
304 _GLIBCXX_END_NAMESPACE_VERSION
305 } // namespace std
306 
307 #endif // __cplusplus <= 201103L
308 
309 #endif // _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS
std
ISO C++ entities toplevel namespace is std.
lfts_config.h
std::void_t
void void_t
A metafunction that always yields void, used for detecting valid types.
Definition: type_traits:2573
std::__detector
Implementation of the detection idiom (negative case).
Definition: type_traits:2579
type_traits