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;
32template<
typename T >
struct remove_reference;
34template<
typename T >
struct identity {
typedef T type; };
35template<
typename T >
using identity_t =
typename identity<T>::type;
37template<
typename T1,
typename T2 >
struct is_same;
39template<
typename T >
struct remove_const;
41template<
typename T >
struct remove_volatile;
43template<
typename T >
struct remove_cv;
45template<
typename T >
struct remove_pointer;
47template<
typename T >
struct remove_extent;
49template<
typename T >
struct remove_all_extents;
53template<
typename,
typename >
54struct is_same : false_type {};
57struct is_same<T, T> : true_type {};
59template<
typename T1,
typename T2 >
60inline constexpr bool is_same_v = is_same<T1, T2>::value;
63struct remove_reference {
typedef T type; };
66struct remove_reference<T &> {
typedef T type; };
69struct remove_reference<T &&> {
typedef T type; };
72using remove_reference_t =
typename remove_reference<T>::type;
74template<
typename T >
struct remove_const {
typedef T type; };
75template<
typename T >
struct remove_const<T const> {
typedef T type; };
76template<
typename T >
using remove_const_t =
typename remove_const<T>::type;
78template<
typename T >
struct remove_volatile {
typedef T type; };
79template<
typename T >
struct remove_volatile<T volatile> {
typedef T type; };
80template<
typename T >
using remove_volatile_t =
typename remove_volatile<T>::type;
83struct remove_cv {
typedef remove_const_t<remove_volatile_t<T>> type; };
86using remove_cv_t =
typename remove_cv<T>::type;
89struct remove_cvref {
using type = remove_cv_t<remove_reference_t<T>>; };
92using remove_cvref_t =
typename remove_cvref<T>::type;
94template<
typename T,
typename >
95struct __remove_pointer_h {
typedef T type; };
97template<
typename T,
typename I >
98struct __remove_pointer_h<T, I*> {
typedef I type; };
100template<
typename T >
101struct remove_pointer : __remove_pointer_h<T, remove_cv_t<T>> {};
103template<
typename T >
104using remove_pointer_t =
typename remove_pointer<T>::type;
107template<
typename T >
108struct remove_extent {
typedef T type; };
110template<
typename T >
111struct remove_extent<T[]> {
typedef T type; };
113template<
typename T,
unsigned long N >
114struct remove_extent<T[N]> {
typedef T type; };
116template<
typename T >
117using remove_extent_t =
typename remove_extent<T>::type;
120template<
typename T >
121struct remove_all_extents {
typedef T type; };
123template<
typename T >
124struct remove_all_extents<T[]> {
typedef typename remove_all_extents<T>::type type; };
126template<
typename T,
unsigned long N >
127struct remove_all_extents<T[N]> {
typedef typename remove_all_extents<T>::type type; };
129template<
typename T >
130using remove_all_extents_t =
typename remove_all_extents<T>::type;
132template<
typename T >
134forward(cxx::remove_reference_t<T> &t)
135{
return static_cast<T &&
>(t); }
137template<
typename T >
139forward(cxx::remove_reference_t<T> &&t)
140{
return static_cast<T &&
>(t); }
142template<
typename T >
143constexpr cxx::remove_reference_t<T> &&
144move(T &&t) {
return static_cast<cxx::remove_reference_t<T> &&
>(t); }
146template<
bool,
typename T =
void >
149template<
typename T >
150struct enable_if<true, T> {
typedef T type; };
152template<
bool C,
typename T =
void >
153using enable_if_t =
typename enable_if<C, T>::type;
155template<
typename T >
156struct is_const : false_type {};
158template<
typename T >
159struct is_const<T const> : true_type {};
161template<
typename T >
162inline constexpr bool is_const_v = is_const<T>::value;
164template<
typename T >
165struct is_volatile : false_type {};
167template<
typename T >
168struct is_volatile<T volatile> : true_type {};
170template<
typename T >
171inline constexpr bool is_volatile_v = is_volatile<T>::value;
173template<
typename T >
174struct is_pointer : false_type {};
176template<
typename T >
177struct is_pointer<T *> : true_type {};
179template<
typename T >
180inline constexpr bool is_pointer_v = is_pointer<T>::value;
183inline constexpr bool is_null_pointer_v = is_same_v<
decltype(
nullptr), remove_cv_t<T>>;
185template<
typename T >
186struct is_reference : false_type {};
188template<
typename T >
189struct is_reference<T &> : true_type {};
191template<
typename T >
192struct is_reference<T &&> : true_type {};
194template<
typename T >
195inline constexpr bool is_reference_v = is_reference<T>::value;
197template<
bool,
typename,
typename >
200template<
bool C,
typename T_TRUE,
typename T_FALSE >
201struct conditional {
typedef T_TRUE type; };
203template<
typename T_TRUE,
typename T_FALSE >
204struct conditional< false, T_TRUE, T_FALSE > {
typedef T_FALSE type; };
206template<
bool C,
typename T_TRUE,
typename T_FALSE >
207using conditional_t =
typename conditional<C, T_TRUE, T_FALSE>::type;
210struct is_enum : integral_constant<bool, __is_enum(T)> {};
212template<
typename T >
213inline constexpr bool is_enum_v = is_enum<T>::value;
216struct is_polymorphic : cxx::integral_constant<bool, __is_polymorphic(T)> {};
218template<
typename T >
struct is_integral : false_type {};
220template<>
struct is_integral<bool> : true_type {};
222template<>
struct is_integral<char> : true_type {};
223template<>
struct is_integral<signed char> : true_type {};
224template<>
struct is_integral<unsigned char> : true_type {};
225template<>
struct is_integral<short> : true_type {};
226template<>
struct is_integral<unsigned short> : true_type {};
227template<>
struct is_integral<int> : true_type {};
228template<>
struct is_integral<unsigned int> : true_type {};
229template<>
struct is_integral<long> : true_type {};
230template<>
struct is_integral<unsigned long> : true_type {};
231template<>
struct is_integral<long long> : true_type {};
232template<>
struct is_integral<unsigned long long> : true_type {};
234template<
typename T >
235inline constexpr bool is_integral_v = is_integral<T>::value;
237template<
typename T,
bool = is_
integral_v<T> || is_enum_v<T> >
238struct __is_signed_helper : integral_constant<bool, static_cast<bool>(T(-1) < T(0))> {};
240template< typename T >
241struct __is_signed_helper<T, false> : integral_constant<bool, false> {};
243template< typename T >
244struct is_signed : __is_signed_helper<T> {};
246template< typename T >
247inline constexpr bool is_signed_v = is_signed<T>::value;
251struct is_array : false_type {};
253template< typename T >
254struct is_array<T[]> : true_type {};
256template< typename T, unsigned long N >
257struct is_array<T[N]> : true_type {};
259template< typename T >
260inline constexpr bool is_array_v = is_array<T>::value;
262template< typename T, unsigned N >
263constexpr unsigned array_size(T const (&)[N]) { return N; }
265template< int SIZE, bool SIGN = false, bool = true > struct int_type_for_size;
267template<> struct int_type_for_size<sizeof(char), true, true>
268{ typedef signed char type; };
270template<> struct int_type_for_size<sizeof(char), false, true>
271{ typedef unsigned char type; };
273template<> struct int_type_for_size<sizeof(short), true, (sizeof(short) > sizeof(char))>
274{
typedef short type; };
276template<>
struct int_type_for_size<sizeof(short), false, (sizeof(short) > sizeof(char))>
277{
typedef unsigned short type; };
279template<>
struct int_type_for_size<sizeof(int), true, (sizeof(int) > sizeof(short))>
280{
typedef int type; };
282template<>
struct int_type_for_size<sizeof(int), false, (sizeof(int) > sizeof(short))>
283{
typedef unsigned int type; };
285template<>
struct int_type_for_size<sizeof(long), true, (sizeof(long) > sizeof(int))>
286{
typedef long type; };
288template<>
struct int_type_for_size<sizeof(long), false, (sizeof(long) > sizeof(int))>
289{
typedef unsigned long type; };
291template<>
struct int_type_for_size<sizeof(long long), true, (sizeof(long long) > sizeof(long))>
292{
typedef long long type; };
294template<>
struct int_type_for_size<sizeof(long long), false, (sizeof(long long) > sizeof(long))>
295{
typedef unsigned long long type; };
297template<
int SIZE,
bool SIGN = false>
298using int_type_for_size_t =
typename int_type_for_size<SIZE, SIGN>::type;
300template<
typename T,
class Enable =
void >
struct underlying_type {};
302template<
typename T >
303struct underlying_type<T, typename enable_if<is_enum_v<T>>::type >
305 typedef int_type_for_size_t<
sizeof(T), is_signed_v<T>> type;
308template<
typename T >
309using underlying_type_t =
typename underlying_type<T>::type;
311template<
typename T >
struct make_signed;
312template<>
struct make_signed<char> {
typedef signed char type; };
313template<>
struct make_signed<unsigned char> {
typedef signed char type; };
314template<>
struct make_signed<signed char> {
typedef signed char type; };
315template<>
struct make_signed<unsigned int> {
typedef signed int type; };
316template<>
struct make_signed<signed int> {
typedef signed int type; };
317template<>
struct make_signed<unsigned long int> {
typedef signed long int type; };
318template<>
struct make_signed<signed long int> {
typedef signed long int type; };
319template<>
struct make_signed<unsigned long long int> {
typedef signed long long int type; };
320template<>
struct make_signed<signed long long int> {
typedef signed long long int type; };
321template<
typename T >
using make_signed_t =
typename make_signed<T>::type;
323template<
typename T >
struct make_unsigned;
324template<>
struct make_unsigned<char> {
typedef unsigned char type; };
325template<>
struct make_unsigned<unsigned char> {
typedef unsigned char type; };
326template<>
struct make_unsigned<signed char> {
typedef unsigned char type; };
327template<>
struct make_unsigned<unsigned int> {
typedef unsigned int type; };
328template<>
struct make_unsigned<signed int> {
typedef unsigned int type; };
329template<>
struct make_unsigned<unsigned long int> {
typedef unsigned long int type; };
330template<>
struct make_unsigned<signed long int> {
typedef unsigned long int type; };
331template<>
struct make_unsigned<unsigned long long int> {
typedef unsigned long long int type; };
332template<>
struct make_unsigned<signed long long int> {
typedef unsigned long long int type; };
333template<
typename T >
using make_unsigned_t =
typename make_unsigned<T>::type;
336template<
typename From,
typename To>
340 struct _true {
char x[2]; };
343 static _true _helper(To
const *);
344 static _false _helper(...);
348 value =
sizeof(_true) ==
sizeof(_helper(
static_cast<From*
>(0)))
352 typedef bool value_type;
355template<
typename From,
typename To>
356inline constexpr bool is_convertible_v = is_convertible<From, To>::value;
358template<
typename T >
359struct is_empty : integral_constant<bool, __is_empty(T)> {};
361template<
typename T >
362inline constexpr bool is_empty_v = is_empty<T>::value;
365#if L4_HAS_BUILTIN(__is_function)
366 template <
typename T >
367 struct is_function : integral_constant<bool, __is_function(T)> {};
369 template <
typename T >
370 struct is_function : integral_constant<bool, !is_reference_v<T>
371 && !is_const_v<const T>> {};
374template<
typename T >
375inline constexpr bool is_function_v = is_function<T>::value;
L4 compiler related defines.