14#pragma GCC system_header
17#include "bits/type_traits.h"
21template<
typename T, T V >
22struct integral_constant
24 static T
const value = V;
26 typedef integral_constant<T, V> type;
29typedef integral_constant<bool, true> true_type;
30typedef integral_constant<bool, false> false_type;
35template<
typename T >
struct remove_reference;
37template<
typename T >
struct identity {
typedef T type; };
38template<
typename T >
using identity_t =
typename identity<T>::type;
40template<
typename T1,
typename T2 >
struct is_same;
42template<
typename T >
struct remove_const;
44template<
typename T >
struct remove_volatile;
46template<
typename T >
struct remove_cv;
48template<
typename T >
struct remove_pointer;
50template<
typename T >
struct remove_extent;
52template<
typename T >
struct remove_all_extents;
56template<
typename,
typename >
57struct is_same : false_type {};
60struct is_same<T, T> : true_type {};
62template<
typename T1,
typename T2 >
63inline constexpr bool is_same_v = is_same<T1, T2>::value;
66struct remove_reference {
typedef T type; };
69struct remove_reference<T &> {
typedef T type; };
72struct remove_reference<T &&> {
typedef T type; };
75using remove_reference_t =
typename remove_reference<T>::type;
77template<
typename T >
struct remove_const {
typedef T type; };
78template<
typename T >
struct remove_const<T const> {
typedef T type; };
79template<
typename T >
using remove_const_t =
typename remove_const<T>::type;
81template<
typename T >
struct remove_volatile {
typedef T type; };
82template<
typename T >
struct remove_volatile<T volatile> {
typedef T type; };
83template<
typename T >
using remove_volatile_t =
typename remove_volatile<T>::type;
86struct remove_cv {
typedef remove_const_t<remove_volatile_t<T>> type; };
89using remove_cv_t =
typename remove_cv<T>::type;
92struct remove_cvref {
using type = remove_cv_t<remove_reference_t<T>>; };
95using remove_cvref_t =
typename remove_cvref<T>::type;
97template<
typename T,
typename >
98struct __remove_pointer_h {
typedef T type; };
100template<
typename T,
typename I >
101struct __remove_pointer_h<T, I*> {
typedef I type; };
103template<
typename T >
104struct remove_pointer : __remove_pointer_h<T, remove_cv_t<T>> {};
106template<
typename T >
107using remove_pointer_t =
typename remove_pointer<T>::type;
110template<
typename T >
111struct remove_extent {
typedef T type; };
113template<
typename T >
114struct remove_extent<T[]> {
typedef T type; };
116template<
typename T,
unsigned long N >
117struct remove_extent<T[N]> {
typedef T type; };
119template<
typename T >
120using remove_extent_t =
typename remove_extent<T>::type;
123template<
typename T >
124struct remove_all_extents {
typedef T type; };
126template<
typename T >
127struct remove_all_extents<T[]> {
typedef typename remove_all_extents<T>::type type; };
129template<
typename T,
unsigned long N >
130struct remove_all_extents<T[N]> {
typedef typename remove_all_extents<T>::type type; };
132template<
typename T >
133using remove_all_extents_t =
typename remove_all_extents<T>::type;
135template<
typename T >
137forward(cxx::remove_reference_t<T> &t)
138{
return static_cast<T &&
>(t); }
140template<
typename T >
142forward(cxx::remove_reference_t<T> &&t)
143{
return static_cast<T &&
>(t); }
145template<
typename T >
146constexpr cxx::remove_reference_t<T> &&
147move(T &&t) {
return static_cast<cxx::remove_reference_t<T> &&
>(t); }
149template<
bool,
typename T =
void >
152template<
typename T >
153struct enable_if<true, T> {
typedef T type; };
155template<
bool C,
typename T =
void >
156using enable_if_t =
typename enable_if<C, T>::type;
158template<
typename T >
159struct is_const : false_type {};
161template<
typename T >
162struct is_const<T const> : true_type {};
164template<
typename T >
165inline constexpr bool is_const_v = is_const<T>::value;
167template<
typename T >
168struct is_volatile : false_type {};
170template<
typename T >
171struct is_volatile<T volatile> : true_type {};
173template<
typename T >
174inline constexpr bool is_volatile_v = is_volatile<T>::value;
176template<
typename T >
177struct is_pointer : false_type {};
179template<
typename T >
180struct is_pointer<T *> : true_type {};
182template<
typename T >
183inline constexpr bool is_pointer_v = is_pointer<T>::value;
186inline constexpr bool is_null_pointer_v = is_same_v<
decltype(
nullptr), remove_cv_t<T>>;
188template<
typename T >
189struct is_reference : false_type {};
191template<
typename T >
192struct is_reference<T &> : true_type {};
194template<
typename T >
195struct is_reference<T &&> : true_type {};
197template<
typename T >
198inline constexpr bool is_reference_v = is_reference<T>::value;
200template<
bool,
typename,
typename >
203template<
bool C,
typename T_TRUE,
typename T_FALSE >
204struct conditional {
typedef T_TRUE type; };
206template<
typename T_TRUE,
typename T_FALSE >
207struct conditional< false, T_TRUE, T_FALSE > {
typedef T_FALSE type; };
209template<
bool C,
typename T_TRUE,
typename T_FALSE >
210using conditional_t =
typename conditional<C, T_TRUE, T_FALSE>::type;
213struct is_enum : integral_constant<bool, __is_enum(T)> {};
215template<
typename T >
216inline constexpr bool is_enum_v = is_enum<T>::value;
219struct is_polymorphic : cxx::integral_constant<bool, __is_polymorphic(T)> {};
221template<
typename T >
struct is_integral : false_type {};
223template<>
struct is_integral<bool> : true_type {};
225template<>
struct is_integral<char> : true_type {};
226template<>
struct is_integral<signed char> : true_type {};
227template<>
struct is_integral<unsigned char> : true_type {};
228template<>
struct is_integral<short> : true_type {};
229template<>
struct is_integral<unsigned short> : true_type {};
230template<>
struct is_integral<int> : true_type {};
231template<>
struct is_integral<unsigned int> : true_type {};
232template<>
struct is_integral<long> : true_type {};
233template<>
struct is_integral<unsigned long> : true_type {};
234template<>
struct is_integral<long long> : true_type {};
235template<>
struct is_integral<unsigned long long> : true_type {};
237template<
typename T >
238inline constexpr bool is_integral_v = is_integral<T>::value;
240template<
typename T,
bool = is_
integral_v<T> || is_enum_v<T> >
241struct __is_signed_helper : integral_constant<bool, static_cast<bool>(T(-1) < T(0))> {};
243template< typename T >
244struct __is_signed_helper<T, false> : integral_constant<bool, false> {};
246template< typename T >
247struct is_signed : __is_signed_helper<T> {};
249template< typename T >
250inline constexpr bool is_signed_v = is_signed<T>::value;
254struct is_array : false_type {};
256template< typename T >
257struct is_array<T[]> : true_type {};
259template< typename T, unsigned long N >
260struct is_array<T[N]> : true_type {};
262template< typename T >
263inline constexpr bool is_array_v = is_array<T>::value;
265template< typename T, unsigned N >
266constexpr unsigned array_size(T const (&)[N]) { return N; }
268template< int SIZE, bool SIGN = false, bool = true > struct int_type_for_size;
270template<> struct int_type_for_size<sizeof(char), true, true>
271{ typedef signed char type; };
273template<> struct int_type_for_size<sizeof(char), false, true>
274{ typedef unsigned char type; };
276template<> struct int_type_for_size<sizeof(short), true, (sizeof(short) > sizeof(char))>
277{
typedef short type; };
279template<>
struct int_type_for_size<sizeof(short), false, (sizeof(short) > sizeof(char))>
280{
typedef unsigned short type; };
282template<>
struct int_type_for_size<sizeof(int), true, (sizeof(int) > sizeof(short))>
283{
typedef int type; };
285template<>
struct int_type_for_size<sizeof(int), false, (sizeof(int) > sizeof(short))>
286{
typedef unsigned int type; };
288template<>
struct int_type_for_size<sizeof(long), true, (sizeof(long) > sizeof(int))>
289{
typedef long type; };
291template<>
struct int_type_for_size<sizeof(long), false, (sizeof(long) > sizeof(int))>
292{
typedef unsigned long type; };
294template<>
struct int_type_for_size<sizeof(long long), true, (sizeof(long long) > sizeof(long))>
295{
typedef long long type; };
297template<>
struct int_type_for_size<sizeof(long long), false, (sizeof(long long) > sizeof(long))>
298{
typedef unsigned long long type; };
300template<
int SIZE,
bool SIGN = false>
301using int_type_for_size_t =
typename int_type_for_size<SIZE, SIGN>::type;
303template<
typename T,
class Enable =
void >
struct underlying_type {};
305template<
typename T >
306struct underlying_type<T, typename enable_if<is_enum_v<T>>::type >
308 typedef int_type_for_size_t<
sizeof(T), is_signed_v<T>> type;
311template<
typename T >
312using underlying_type_t =
typename underlying_type<T>::type;
314template<
typename T >
struct make_signed;
315template<>
struct make_signed<char> {
typedef signed char type; };
316template<>
struct make_signed<unsigned char> {
typedef signed char type; };
317template<>
struct make_signed<signed char> {
typedef signed char type; };
318template<>
struct make_signed<unsigned int> {
typedef signed int type; };
319template<>
struct make_signed<signed int> {
typedef signed int type; };
320template<>
struct make_signed<unsigned long int> {
typedef signed long int type; };
321template<>
struct make_signed<signed long int> {
typedef signed long int type; };
322template<>
struct make_signed<unsigned long long int> {
typedef signed long long int type; };
323template<>
struct make_signed<signed long long int> {
typedef signed long long int type; };
324template<
typename T >
using make_signed_t =
typename make_signed<T>::type;
326template<
typename T >
struct make_unsigned;
327template<>
struct make_unsigned<char> {
typedef unsigned char type; };
328template<>
struct make_unsigned<unsigned char> {
typedef unsigned char type; };
329template<>
struct make_unsigned<signed char> {
typedef unsigned char type; };
330template<>
struct make_unsigned<unsigned int> {
typedef unsigned int type; };
331template<>
struct make_unsigned<signed int> {
typedef unsigned int type; };
332template<>
struct make_unsigned<unsigned long int> {
typedef unsigned long int type; };
333template<>
struct make_unsigned<signed long int> {
typedef unsigned long int type; };
334template<>
struct make_unsigned<unsigned long long int> {
typedef unsigned long long int type; };
335template<>
struct make_unsigned<signed long long int> {
typedef unsigned long long int type; };
336template<
typename T >
using make_unsigned_t =
typename make_unsigned<T>::type;
339template<
typename From,
typename To>
343 struct _true {
char x[2]; };
346 static _true _helper(To
const *);
347 static _false _helper(...);
351 value =
sizeof(_true) ==
sizeof(_helper(
static_cast<From*
>(0)))
355 typedef bool value_type;
358template<
typename From,
typename To>
359inline constexpr bool is_convertible_v = is_convertible<From, To>::value;
361template<
typename T >
362struct is_empty : integral_constant<bool, __is_empty(T)> {};
364template<
typename T >
365inline constexpr bool is_empty_v = is_empty<T>::value;
368#if L4_HAS_BUILTIN(__is_function)
369 template <
typename T >
370 struct is_function : integral_constant<bool, __is_function(T)> {};
372 template <
typename T >
373 struct is_function : integral_constant<bool, !is_reference_v<T>
374 && !is_const_v<const T>> {};
377template<
typename T >
378inline constexpr bool is_function_v = is_function<T>::value;
L4 compiler related defines.