25#pragma GCC system_header
27#include "bits/type_traits.h"
30#define CXX_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
35template<
typename T, T V >
36struct integral_constant
38 static T
const value = V;
40 typedef integral_constant<T, V> type;
43typedef integral_constant<bool, true> true_type;
44typedef integral_constant<bool, false> false_type;
46template<
typename T >
struct remove_reference;
48template<
typename T >
struct identity {
typedef T type; };
49template<
typename T >
using identity_t =
typename identity<T>::type;
51template<
typename T1,
typename T2 >
struct is_same;
53template<
typename T >
struct remove_const;
55template<
typename T >
struct remove_volatile;
57template<
typename T >
struct remove_cv;
59template<
typename T >
struct remove_pointer;
61template<
typename T >
struct remove_extent;
63template<
typename T >
struct remove_all_extents;
67template<
typename,
typename >
68struct is_same : false_type {};
71struct is_same<T, T> : true_type {};
74struct remove_reference {
typedef T type; };
77struct remove_reference<T &> {
typedef T type; };
79#if __cplusplus >= 201103L
81struct remove_reference<T &&> {
typedef T type; };
85using remove_reference_t =
typename remove_reference<T>::type;
87template<
typename T >
struct remove_const {
typedef T type; };
88template<
typename T >
struct remove_const<T const> {
typedef T type; };
89template<
typename T >
using remove_const_t =
typename remove_const<T>::type;
91template<
typename T >
struct remove_volatile {
typedef T type; };
92template<
typename T >
struct remove_volatile<T volatile> {
typedef T type; };
93template<
typename T >
using remove_volatile_t =
typename remove_volatile<T>::type;
96struct remove_cv {
typedef remove_const_t<remove_volatile_t<T>> type; };
99using remove_cv_t =
typename remove_cv<T>::type;
102template<
typename T,
typename >
103struct __remove_pointer_h {
typedef T type; };
105template<
typename T,
typename I >
106struct __remove_pointer_h<T, I*> {
typedef I type; };
108template<
typename T >
109struct remove_pointer : __remove_pointer_h<T, remove_cv_t<T>> {};
111template<
typename T >
112using remove_pointer_t =
typename remove_pointer<T>::type;
115template<
typename T >
116struct remove_extent {
typedef T type; };
118template<
typename T >
119struct remove_extent<T[]> {
typedef T type; };
121template<
typename T,
unsigned long N >
122struct remove_extent<T[N]> {
typedef T type; };
124template<
typename T >
125using remove_extent_t =
typename remove_extent<T>::type;
128template<
typename T >
129struct remove_all_extents {
typedef T type; };
131template<
typename T >
132struct remove_all_extents<T[]> {
typedef typename remove_all_extents<T>::type type; };
134template<
typename T,
unsigned long N >
135struct remove_all_extents<T[N]> {
typedef typename remove_all_extents<T>::type type; };
137template<
typename T >
138using remove_all_extents_t =
typename remove_all_extents<T>::type;
140#if __cplusplus >= 201103L
142template<
typename T >
144forward(cxx::remove_reference_t<T> &t)
145{
return static_cast<T &&
>(t); }
147template<
typename T >
149forward(cxx::remove_reference_t<T> &&t)
150{
return static_cast<T &&
>(t); }
152template<
typename T >
153inline cxx::remove_reference_t<T> &&
154move(T &&t) {
return static_cast<cxx::remove_reference_t<T> &&
>(t); }
156template<
typename T >
157inline T move(T t) {
return t; }
160template<
bool,
typename T =
void >
163template<
typename T >
164struct enable_if<true, T> {
typedef T type; };
166template<
bool C,
typename T =
void >
167using enable_if_t =
typename enable_if<C, T>::type;
169template<
typename T >
170struct is_const : false_type {};
172template<
typename T >
173struct is_const<T const> : true_type {};
175template<
bool,
typename,
typename >
178template<
bool C,
typename T_TRUE,
typename T_FALSE >
179struct conditional {
typedef T_TRUE type; };
181template<
typename T_TRUE,
typename T_FALSE >
182struct conditional< false, T_TRUE, T_FALSE > {
typedef T_FALSE type; };
184template<
bool C,
typename T_TRUE,
typename T_FALSE >
185using conditional_t =
typename conditional<C, T_TRUE, T_FALSE>::type;
188struct is_enum : integral_constant<bool, __is_enum(T)> {};
191struct is_polymorphic : cxx::integral_constant<bool, __is_polymorphic(T)> {};
193template<
typename T >
struct is_integral : false_type {};
195template<>
struct is_integral<bool> : true_type {};
197template<>
struct is_integral<char> : true_type {};
198template<>
struct is_integral<signed char> : true_type {};
199template<>
struct is_integral<unsigned char> : true_type {};
200template<>
struct is_integral<short> : true_type {};
201template<>
struct is_integral<unsigned short> : true_type {};
202template<>
struct is_integral<int> : true_type {};
203template<>
struct is_integral<unsigned int> : true_type {};
204template<>
struct is_integral<long> : true_type {};
205template<>
struct is_integral<unsigned long> : true_type {};
206template<>
struct is_integral<long long> : true_type {};
207template<>
struct is_integral<unsigned long long> : true_type {};
209template< typename T, bool = is_integral<T>::value || is_enum<T>::value >
210struct __is_signed_helper : integral_constant<bool, static_cast<bool>(T(-1) < T(0))> {};
212template< typename T >
213struct __is_signed_helper<T, false> : integral_constant<bool, false> {};
215template< typename T >
216struct is_signed : __is_signed_helper<T> {};
220struct is_array : false_type {};
222template< typename T >
223struct is_array<T[]> : true_type {};
225template< typename T, unsigned long N >
226struct is_array<T[N]> : true_type {};
228template< typename T, unsigned N >
229constexpr unsigned array_size(T const (&)[N]) { return N; }
231template< int SIZE, bool SIGN = false, bool = true > struct int_type_for_size;
233template<> struct int_type_for_size<sizeof(char), true, true>
234{ typedef signed char type; };
236template<> struct int_type_for_size<sizeof(char), false, true>
237{ typedef unsigned char type; };
239template<> struct int_type_for_size<sizeof(short), true, (sizeof(short) > sizeof(char))>
240{
typedef short type; };
242template<>
struct int_type_for_size<sizeof(short), false, (sizeof(short) > sizeof(char))>
243{
typedef unsigned short type; };
245template<>
struct int_type_for_size<sizeof(int), true, (sizeof(int) > sizeof(short))>
246{
typedef int type; };
248template<>
struct int_type_for_size<sizeof(int), false, (sizeof(int) > sizeof(short))>
249{
typedef unsigned int type; };
251template<>
struct int_type_for_size<sizeof(long), true, (sizeof(long) > sizeof(int))>
252{
typedef long type; };
254template<>
struct int_type_for_size<sizeof(long), false, (sizeof(long) > sizeof(int))>
255{
typedef unsigned long type; };
257template<>
struct int_type_for_size<sizeof(long long), true, (sizeof(long long) > sizeof(long))>
258{
typedef long long type; };
260template<>
struct int_type_for_size<sizeof(long long), false, (sizeof(long long) > sizeof(long))>
261{
typedef unsigned long long type; };
263template<
int SIZE,
bool SIGN = false>
264using int_type_for_size_t =
typename int_type_for_size<SIZE, SIGN>::type;
266template<
typename T,
class Enable =
void >
struct underlying_type {};
268template<
typename T >
269struct underlying_type<T, typename enable_if<is_enum<T>::value>::type >
271 typedef typename int_type_for_size<
sizeof(T), is_signed<T>::value>::type type;
274template<
typename T >
275using underlying_type_t =
typename underlying_type<T>::type;
277template<
typename T >
struct make_signed;
278template<>
struct make_signed<char> {
typedef signed char type; };
279template<>
struct make_signed<unsigned char> {
typedef signed char type; };
280template<>
struct make_signed<signed char> {
typedef signed char type; };
281template<>
struct make_signed<unsigned int> {
typedef signed int type; };
282template<>
struct make_signed<signed int> {
typedef signed int type; };
283template<>
struct make_signed<unsigned long int> {
typedef signed long int type; };
284template<>
struct make_signed<signed long int> {
typedef signed long int type; };
285template<>
struct make_signed<unsigned long long int> {
typedef signed long long int type; };
286template<>
struct make_signed<signed long long int> {
typedef signed long long int type; };
287template<
typename T >
using make_signed_t =
typename make_signed<T>::type;
289template<
typename T >
struct make_unsigned;
290template<>
struct make_unsigned<char> {
typedef unsigned char type; };
291template<>
struct make_unsigned<unsigned char> {
typedef unsigned char type; };
292template<>
struct make_unsigned<signed char> {
typedef unsigned char type; };
293template<>
struct make_unsigned<unsigned int> {
typedef unsigned int type; };
294template<>
struct make_unsigned<signed int> {
typedef unsigned int type; };
295template<>
struct make_unsigned<unsigned long int> {
typedef unsigned long int type; };
296template<>
struct make_unsigned<signed long int> {
typedef unsigned long int type; };
297template<>
struct make_unsigned<unsigned long long int> {
typedef unsigned long long int type; };
298template<>
struct make_unsigned<signed long long int> {
typedef unsigned long long int type; };
299template<
typename T >
using make_unsigned_t =
typename make_unsigned<T>::type;
302template<
typename From,
typename To>
306 struct _true {
char x[2]; };
309 static _true _helper(To
const *);
310 static _false _helper(...);
314 value =
sizeof(_true) ==
sizeof(_helper(
static_cast<From*
>(0)))
318 typedef bool value_type;