-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype_traits.hpp
165 lines (143 loc) · 2.82 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef FT_CONTAINERS_TYPE_TRAITS_HPP
#define FT_CONTAINERS_TYPE_TRAITS_HPP
namespace ft {
struct true_type {
};
struct false_type {
};
template<bool>
struct truth_type {
typedef false_type type;
};
template<>
struct truth_type<true> {
typedef true_type type;
};
template<class _Sp, class _Tp>
struct traitor {
enum {
value = bool(_Sp::value) || bool(_Tp::value)
};
typedef typename truth_type<value>::type type;
};
template<typename, typename>
struct are_same {
enum {
value = 0
};
typedef false_type type;
};
template<typename _Tp>
struct are_same<_Tp, _Tp> {
enum {
value = 1
};
typedef true_type type;
};
template<typename _Tp>
struct is_void {
enum {
value = 0
};
typedef false_type type;
};
template<>
struct is_void<void> {
enum {
value = 1
};
typedef true_type type;
};
template<typename _Tp>
struct is_integer {
enum {
value = 0
};
typedef false_type type;
};
template<>
struct is_integer<bool> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<char> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<signed char> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<unsigned char> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<short> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<unsigned short> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<int> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<unsigned int> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<long> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<unsigned long> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<long long> {
enum {
value = 1
};
typedef true_type type;
};
template<>
struct is_integer<unsigned long long> {
enum {
value = 1
};
typedef true_type type;
};
}
#endif