1// Variable Templates For Type Traits -*- C++ -*-
3// Copyright (C) 2014-2019 Free Software Foundation, Inc.
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)
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.
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.
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/>.
25/** @file experimental/type_traits
26 * This is a TS C++ Library header.
30// N3932 Variable Templates For Type Traits (Revision 1)
33#ifndef _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS
34#define _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS 1
36#pragma GCC system_header
38#if __cplusplus >= 201402L
41#include <experimental/bits/lfts_config.h>
43namespace std _GLIBCXX_VISIBILITY(default)
45_GLIBCXX_BEGIN_NAMESPACE_VERSION
49inline namespace fundamentals_v1
51#define __cpp_lib_experimental_type_trait_variable_templates 201402
53// See C++14 20.10.4.1, primary type categories
54template <typename _Tp>
55 constexpr bool is_void_v = is_void<_Tp>::value;
56template <typename _Tp>
57 constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
58template <typename _Tp>
59 constexpr bool is_integral_v = is_integral<_Tp>::value;
60template <typename _Tp>
61 constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
62template <typename _Tp>
63 constexpr bool is_array_v = is_array<_Tp>::value;
64template <typename _Tp>
65 constexpr bool is_pointer_v = is_pointer<_Tp>::value;
66template <typename _Tp>
67 constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
68template <typename _Tp>
69 constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
70template <typename _Tp>
71 constexpr bool is_member_object_pointer_v =
72 is_member_object_pointer<_Tp>::value;
73template <typename _Tp>
74 constexpr bool is_member_function_pointer_v =
75 is_member_function_pointer<_Tp>::value;
76template <typename _Tp>
77 constexpr bool is_enum_v = is_enum<_Tp>::value;
78template <typename _Tp>
79 constexpr bool is_union_v = is_union<_Tp>::value;
80template <typename _Tp>
81 constexpr bool is_class_v = is_class<_Tp>::value;
82template <typename _Tp>
83 constexpr bool is_function_v = is_function<_Tp>::value;
85// See C++14 20.10.4.2, composite type categories
86template <typename _Tp>
87 constexpr bool is_reference_v = is_reference<_Tp>::value;
88template <typename _Tp>
89 constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
90template <typename _Tp>
91 constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
92template <typename _Tp>
93 constexpr bool is_object_v = is_object<_Tp>::value;
94template <typename _Tp>
95 constexpr bool is_scalar_v = is_scalar<_Tp>::value;
96template <typename _Tp>
97 constexpr bool is_compound_v = is_compound<_Tp>::value;
98template <typename _Tp>
99 constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
101// See C++14 20.10.4.3, type properties
102template <typename _Tp>
103 constexpr bool is_const_v = is_const<_Tp>::value;
104template <typename _Tp>
105 constexpr bool is_volatile_v = is_volatile<_Tp>::value;
106template <typename _Tp>
107 constexpr bool is_trivial_v = is_trivial<_Tp>::value;
108template <typename _Tp>
109 constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
110template <typename _Tp>
111 constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
112template <typename _Tp>
113 constexpr bool is_pod_v = is_pod<_Tp>::value;
114template <typename _Tp>
115 constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
116template <typename _Tp>
117 constexpr bool is_empty_v = is_empty<_Tp>::value;
118template <typename _Tp>
119 constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value;
120template <typename _Tp>
121 constexpr bool is_abstract_v = is_abstract<_Tp>::value;
122template <typename _Tp>
123 constexpr bool is_final_v = is_final<_Tp>::value;
124template <typename _Tp>
125 constexpr bool is_signed_v = is_signed<_Tp>::value;
126template <typename _Tp>
127 constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;
128template <typename _Tp, typename... _Args>
129 constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
130template <typename _Tp>
131 constexpr bool is_default_constructible_v =
132 is_default_constructible<_Tp>::value;
133template <typename _Tp>
134 constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
135template <typename _Tp>
136 constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
137template <typename _Tp, typename _Up>
138 constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value;
139template <typename _Tp>
140 constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
141template <typename _Tp>
142 constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
143template <typename _Tp>
144 constexpr bool is_destructible_v = is_destructible<_Tp>::value;
145template <typename _Tp, typename... _Args>
146 constexpr bool is_trivially_constructible_v =
147 is_trivially_constructible<_Tp, _Args...>::value;
148template <typename _Tp>
149 constexpr bool is_trivially_default_constructible_v =
150 is_trivially_default_constructible<_Tp>::value;
151template <typename _Tp>
152 constexpr bool is_trivially_copy_constructible_v =
153 is_trivially_copy_constructible<_Tp>::value;
154template <typename _Tp>
155 constexpr bool is_trivially_move_constructible_v =
156 is_trivially_move_constructible<_Tp>::value;
157template <typename _Tp, typename _Up>
158 constexpr bool is_trivially_assignable_v =
159 is_trivially_assignable<_Tp, _Up>::value;
160template <typename _Tp>
161 constexpr bool is_trivially_copy_assignable_v =
162 is_trivially_copy_assignable<_Tp>::value;
163template <typename _Tp>
164 constexpr bool is_trivially_move_assignable_v =
165 is_trivially_move_assignable<_Tp>::value;
166template <typename _Tp>
167 constexpr bool is_trivially_destructible_v =
168 is_trivially_destructible<_Tp>::value;
169template <typename _Tp, typename... _Args>
170 constexpr bool is_nothrow_constructible_v =
171 is_nothrow_constructible<_Tp, _Args...>::value;
172template <typename _Tp>
173 constexpr bool is_nothrow_default_constructible_v =
174 is_nothrow_default_constructible<_Tp>::value;
175template <typename _Tp>
176 constexpr bool is_nothrow_copy_constructible_v =
177 is_nothrow_copy_constructible<_Tp>::value;
178template <typename _Tp>
179 constexpr bool is_nothrow_move_constructible_v =
180 is_nothrow_move_constructible<_Tp>::value;
181template <typename _Tp, typename _Up>
182 constexpr bool is_nothrow_assignable_v =
183 is_nothrow_assignable<_Tp, _Up>::value;
184template <typename _Tp>
185 constexpr bool is_nothrow_copy_assignable_v =
186 is_nothrow_copy_assignable<_Tp>::value;
187template <typename _Tp>
188 constexpr bool is_nothrow_move_assignable_v =
189 is_nothrow_move_assignable<_Tp>::value;
190template <typename _Tp>
191 constexpr bool is_nothrow_destructible_v =
192 is_nothrow_destructible<_Tp>::value;
193template <typename _Tp>
194 constexpr bool has_virtual_destructor_v =
195 has_virtual_destructor<_Tp>::value;
197// See C++14 20.10.5, type property queries
198template <typename _Tp>
199 constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
200template <typename _Tp>
201 constexpr size_t rank_v = rank<_Tp>::value;
202template <typename _Tp, unsigned _Idx = 0>
203 constexpr size_t extent_v = extent<_Tp, _Idx>::value;
205// See C++14 20.10.6, type relations
206template <typename _Tp, typename _Up>
207 constexpr bool is_same_v = is_same<_Tp, _Up>::value;
208template <typename _Base, typename _Derived>
209 constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
210template <typename _From, typename _To>
211 constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
214 // 3.3.2, Other type transformations
215 // invocation_type (still unimplemented)
216 // raw_invocation_type (still unimplemented)
217 // invocation_type_t (still unimplemented)
218 // raw_invocation_type_t (still unimplemented)
219} // namespace fundamentals_v1
221inline namespace fundamentals_v2
223#define __cpp_lib_experimental_detect 201505
227template<typename...> using void_t = void;
232 ~nonesuch() = delete;
233 nonesuch(nonesuch const&) = delete;
234 void operator=(nonesuch const&) = delete;
237template<template<typename...> class _Op, typename... _Args>
239 = typename std::__detector<nonesuch, void, _Op, _Args...>::value_t;
241template<template<typename...> class _Op, typename... _Args>
242 constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
244template<template<typename...> class _Op, typename... _Args>
246 = typename std::__detector<nonesuch, void, _Op, _Args...>::type;
248template<typename _Default, template<typename...> class _Op, typename... _Args>
249 using detected_or = std::__detected_or<_Default, _Op, _Args...>;
251template<typename _Default, template<typename...> class _Op, typename... _Args>
252 using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type;
254template<typename _Expected, template<typename...> class _Op, typename... _Args>
255 using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>;
257template<typename _Expected, template<typename...> class _Op, typename... _Args>
258 constexpr bool is_detected_exact_v
259 = is_detected_exact<_Expected, _Op, _Args...>::value;
261template<typename _To, template<typename...> class _Op, typename... _Args>
262 using is_detected_convertible
263 = is_convertible<detected_t<_Op, _Args...>, _To>;
265template<typename _To, template<typename...> class _Op, typename... _Args>
266 constexpr bool is_detected_convertible_v
267 = is_detected_convertible<_To, _Op, _Args...>::value;
269#define __cpp_lib_experimental_logical_traits 201511
271template<typename... _Bn>
276template<typename... _Bn>
281template<typename _Pp>
286template<typename... _Bn>
287 constexpr bool conjunction_v
288 = conjunction<_Bn...>::value;
290template<typename... _Bn>
291 constexpr bool disjunction_v
292 = disjunction<_Bn...>::value;
294template<typename _Pp>
295 constexpr bool negation_v
296 = negation<_Pp>::value;
297} // namespace fundamentals_v2
298} // namespace experimental
300_GLIBCXX_END_NAMESPACE_VERSION
303#endif // __cplusplus <= 201103L
305#endif // _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS