25#pragma GCC system_header
28#include "bits/type_traits.h"
32template<
typename T, T V >
33struct integral_constant
35 static T
const value = V;
37 typedef integral_constant<T, V> type;
40typedef integral_constant<bool, true> true_type;
41typedef integral_constant<bool, false> false_type;
43template<
typename T >
struct remove_reference;
45template<
typename T >
struct identity {
typedef T type; };
46template<
typename T >
using identity_t =
typename identity<T>::type;
48template<
typename T1,
typename T2 >
struct is_same;
50template<
typename T >
struct remove_const;
52template<
typename T >
struct remove_volatile;
54template<
typename T >
struct remove_cv;
56template<
typename T >
struct remove_pointer;
58template<
typename T >
struct remove_extent;
60template<
typename T >
struct remove_all_extents;
64template<
typename,
typename >
65struct is_same : false_type {};
68struct is_same<T, T> : true_type {};
70template<
typename T1,
typename T2 >
71inline constexpr bool is_same_v = is_same<T1, T2>::value;
74struct remove_reference {
typedef T type; };
77struct remove_reference<T &> {
typedef T type; };
80struct remove_reference<T &&> {
typedef T type; };
83using remove_reference_t =
typename remove_reference<T>::type;
85template<
typename T >
struct remove_const {
typedef T type; };
86template<
typename T >
struct remove_const<T const> {
typedef T type; };
87template<
typename T >
using remove_const_t =
typename remove_const<T>::type;
89template<
typename T >
struct remove_volatile {
typedef T type; };
90template<
typename T >
struct remove_volatile<T volatile> {
typedef T type; };
91template<
typename T >
using remove_volatile_t =
typename remove_volatile<T>::type;
94struct remove_cv {
typedef remove_const_t<remove_volatile_t<T>> type; };
97using remove_cv_t =
typename remove_cv<T>::type;
100struct remove_cvref {
using type = remove_cv_t<remove_reference_t<T>>; };
102template<
typename T >
103using remove_cvref_t =
typename remove_cvref<T>::type;
105template<
typename T,
typename >
106struct __remove_pointer_h {
typedef T type; };
108template<
typename T,
typename I >
109struct __remove_pointer_h<T, I*> {
typedef I type; };
111template<
typename T >
112struct remove_pointer : __remove_pointer_h<T, remove_cv_t<T>> {};
114template<
typename T >
115using remove_pointer_t =
typename remove_pointer<T>::type;
118template<
typename T >
119struct remove_extent {
typedef T type; };
121template<
typename T >
122struct remove_extent<T[]> {
typedef T type; };
124template<
typename T,
unsigned long N >
125struct remove_extent<T[N]> {
typedef T type; };
127template<
typename T >
128using remove_extent_t =
typename remove_extent<T>::type;
131template<
typename T >
132struct remove_all_extents {
typedef T type; };
134template<
typename T >
135struct remove_all_extents<T[]> {
typedef typename remove_all_extents<T>::type type; };
137template<
typename T,
unsigned long N >
138struct remove_all_extents<T[N]> {
typedef typename remove_all_extents<T>::type type; };
140template<
typename T >
141using remove_all_extents_t =
typename remove_all_extents<T>::type;
143template<
typename T >
145forward(cxx::remove_reference_t<T> &t)
146{
return static_cast<T &&
>(t); }
148template<
typename T >
150forward(cxx::remove_reference_t<T> &&t)
151{
return static_cast<T &&
>(t); }
153template<
typename T >
154constexpr cxx::remove_reference_t<T> &&
155move(T &&t) {
return static_cast<cxx::remove_reference_t<T> &&
>(t); }
157template<
bool,
typename T =
void >
160template<
typename T >
161struct enable_if<true, T> {
typedef T type; };
163template<
bool C,
typename T =
void >
164using enable_if_t =
typename enable_if<C, T>::type;
166template<
typename T >
167struct is_const : false_type {};
169template<
typename T >
170struct is_const<T const> : true_type {};
172template<
typename T >
173inline constexpr bool is_const_v = is_const<T>::value;
175template<
typename T >
176struct is_volatile : false_type {};
178template<
typename T >
179struct is_volatile<T volatile> : true_type {};
181template<
typename T >
182inline constexpr bool is_volatile_v = is_volatile<T>::value;
184template<
typename T >
185struct is_pointer : false_type {};
187template<
typename T >
188struct is_pointer<T *> : true_type {};
190template<
typename T >
191inline constexpr bool is_pointer_v = is_pointer<T>::value;
194inline constexpr bool is_null_pointer_v = is_same_v<
decltype(
nullptr), remove_cv_t<T>>;
196template<
typename T >
197struct is_reference : false_type {};
199template<
typename T >
200struct is_reference<T &> : true_type {};
202template<
typename T >
203struct is_reference<T &&> : true_type {};
205template<
typename T >
206inline constexpr bool is_reference_v = is_reference<T>::value;
208template<
bool,
typename,
typename >
211template<
bool C,
typename T_TRUE,
typename T_FALSE >
212struct conditional {
typedef T_TRUE type; };
214template<
typename T_TRUE,
typename T_FALSE >
215struct conditional< false, T_TRUE, T_FALSE > {
typedef T_FALSE type; };
217template<
bool C,
typename T_TRUE,
typename T_FALSE >
218using conditional_t =
typename conditional<C, T_TRUE, T_FALSE>::type;
221struct is_enum : integral_constant<bool, __is_enum(T)> {};
223template<
typename T >
224inline constexpr bool is_enum_v = is_enum<T>::value;
227struct is_polymorphic : cxx::integral_constant<bool, __is_polymorphic(T)> {};
229template<
typename T >
struct is_integral : false_type {};
231template<>
struct is_integral<bool> : true_type {};
233template<>
struct is_integral<char> : true_type {};
234template<>
struct is_integral<signed char> : true_type {};
235template<>
struct is_integral<unsigned char> : true_type {};
236template<>
struct is_integral<short> : true_type {};
237template<>
struct is_integral<unsigned short> : true_type {};
238template<>
struct is_integral<int> : true_type {};
239template<>
struct is_integral<unsigned int> : true_type {};
240template<>
struct is_integral<long> : true_type {};
241template<>
struct is_integral<unsigned long> : true_type {};
242template<>
struct is_integral<long long> : true_type {};
243template<>
struct is_integral<unsigned long long> : true_type {};
245template<
typename T >
246inline constexpr bool is_integral_v = is_integral<T>::value;
248template<
typename T,
bool = is_
integral_v<T> || is_enum_v<T> >
249struct __is_signed_helper : integral_constant<bool, static_cast<bool>(T(-1) < T(0))> {};
251template< typename T >
252struct __is_signed_helper<T, false> : integral_constant<bool, false> {};
254template< typename T >
255struct is_signed : __is_signed_helper<T> {};
257template< typename T >
258inline constexpr bool is_signed_v = is_signed<T>::value;
262struct is_array : false_type {};
264template< typename T >
265struct is_array<T[]> : true_type {};
267template< typename T, unsigned long N >
268struct is_array<T[N]> : true_type {};
270template< typename T >
271inline constexpr bool is_array_v = is_array<T>::value;
273template< typename T, unsigned N >
274constexpr unsigned array_size(T const (&)[N]) { return N; }
276template< int SIZE, bool SIGN = false, bool = true > struct int_type_for_size;
278template<> struct int_type_for_size<sizeof(char), true, true>
279{ typedef signed char type; };
281template<> struct int_type_for_size<sizeof(char), false, true>
282{ typedef unsigned char type; };
284template<> struct int_type_for_size<sizeof(short), true, (sizeof(short) > sizeof(char))>
285{
typedef short type; };
287template<>
struct int_type_for_size<sizeof(short), false, (sizeof(short) > sizeof(char))>
288{
typedef unsigned short type; };
290template<>
struct int_type_for_size<sizeof(int), true, (sizeof(int) > sizeof(short))>
291{
typedef int type; };
293template<>
struct int_type_for_size<sizeof(int), false, (sizeof(int) > sizeof(short))>
294{
typedef unsigned int type; };
296template<>
struct int_type_for_size<sizeof(long), true, (sizeof(long) > sizeof(int))>
297{
typedef long type; };
299template<>
struct int_type_for_size<sizeof(long), false, (sizeof(long) > sizeof(int))>
300{
typedef unsigned long type; };
302template<>
struct int_type_for_size<sizeof(long long), true, (sizeof(long long) > sizeof(long))>
303{
typedef long long type; };
305template<>
struct int_type_for_size<sizeof(long long), false, (sizeof(long long) > sizeof(long))>
306{
typedef unsigned long long type; };
308template<
int SIZE,
bool SIGN = false>
309using int_type_for_size_t =
typename int_type_for_size<SIZE, SIGN>::type;
311template<
typename T,
class Enable =
void >
struct underlying_type {};
313template<
typename T >
314struct underlying_type<T, typename enable_if<is_enum_v<T>>::type >
316 typedef int_type_for_size_t<
sizeof(T), is_signed_v<T>> type;
319template<
typename T >
320using underlying_type_t =
typename underlying_type<T>::type;
322template<
typename T >
struct make_signed;
323template<>
struct make_signed<char> {
typedef signed char type; };
324template<>
struct make_signed<unsigned char> {
typedef signed char type; };
325template<>
struct make_signed<signed char> {
typedef signed char type; };
326template<>
struct make_signed<unsigned int> {
typedef signed int type; };
327template<>
struct make_signed<signed int> {
typedef signed int type; };
328template<>
struct make_signed<unsigned long int> {
typedef signed long int type; };
329template<>
struct make_signed<signed long int> {
typedef signed long int type; };
330template<>
struct make_signed<unsigned long long int> {
typedef signed long long int type; };
331template<>
struct make_signed<signed long long int> {
typedef signed long long int type; };
332template<
typename T >
using make_signed_t =
typename make_signed<T>::type;
334template<
typename T >
struct make_unsigned;
335template<>
struct make_unsigned<char> {
typedef unsigned char type; };
336template<>
struct make_unsigned<unsigned char> {
typedef unsigned char type; };
337template<>
struct make_unsigned<signed char> {
typedef unsigned char type; };
338template<>
struct make_unsigned<unsigned int> {
typedef unsigned int type; };
339template<>
struct make_unsigned<signed int> {
typedef unsigned int type; };
340template<>
struct make_unsigned<unsigned long int> {
typedef unsigned long int type; };
341template<>
struct make_unsigned<signed long int> {
typedef unsigned long int type; };
342template<>
struct make_unsigned<unsigned long long int> {
typedef unsigned long long int type; };
343template<>
struct make_unsigned<signed long long int> {
typedef unsigned long long int type; };
344template<
typename T >
using make_unsigned_t =
typename make_unsigned<T>::type;
347template<
typename From,
typename To>
351 struct _true {
char x[2]; };
354 static _true _helper(To
const *);
355 static _false _helper(...);
359 value =
sizeof(_true) ==
sizeof(_helper(
static_cast<From*
>(0)))
363 typedef bool value_type;
366template<
typename From,
typename To>
367inline constexpr bool is_convertible_v = is_convertible<From, To>::value;
369template<
typename T >
370struct is_empty : integral_constant<bool, __is_empty(T)> {};
372template<
typename T >
373inline constexpr bool is_empty_v = is_empty<T>::value;
376#if L4_HAS_BUILTIN(__is_function)
377 template <
typename T >
378 struct is_function : integral_constant<bool, __is_function(T)> {};
380 template <
typename T >
381 struct is_function : integral_constant<bool, !is_reference_v<T>
382 && !is_const_v<const T>> {};
385template<
typename T >
386inline constexpr bool is_function_v = is_function<T>::value;
L4 compiler related defines.