-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype_traits.hpp
97 lines (71 loc) · 2.08 KB
/
type_traits.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pragma once
namespace ft {
template <bool B, class T = void>
struct enable_if {};
template <class T>
struct enable_if<true, T> {
typedef T type;
};
template <class T>
struct remove_const {
typedef T type;
};
template <class T>
struct remove_const<const T> {
typedef T type;
};
template <class T, T val>
struct integral_constant {
typedef integral_constant<T, val> type;
typedef T value_type;
static const T value = val;
operator value_type() const {
return value;
}
};
template <class T, T val>
T const integral_constant<T, val>::value;
template <bool val>
struct integral_constant<bool, val> {
typedef integral_constant<bool, val> type;
typedef bool value_type;
static const bool value = val;
operator value_type() const {
return value;
}
};
template <bool val>
bool const integral_constant<bool, val>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
template <class T>
struct is_integral : public false_type {};
template <class T>
struct is_integral<const T> : public is_integral<T> {};
template <class T>
struct is_integral<volatile const T> : public is_integral<T> {};
template <class T>
struct is_integral<volatile T> : public is_integral<T> {};
template <>
struct is_integral<unsigned char> : public true_type {};
template <>
struct is_integral<unsigned short> : public true_type {};
template <>
struct is_integral<unsigned int> : public true_type {};
template <>
struct is_integral<unsigned long> : public true_type {};
template <>
struct is_integral<signed char> : public true_type {};
template <>
struct is_integral<short> : public true_type {};
template <>
struct is_integral<int> : public true_type {};
template <>
struct is_integral<long> : public true_type {};
template <>
struct is_integral<char> : public true_type {};
template <>
struct is_integral<bool> : public true_type {};
template <>
struct is_integral<wchar_t> : public true_type {};
} // namespace ft