summaryrefslogtreecommitdiff
path: root/src/jit/jitstd/type_traits.h
blob: f0f8518c409339cb891f1c1ef4670193b8a9dd62 (plain)
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.


#pragma once

namespace jitstd
{
template <typename T>
struct remove_const
{
    typedef T type;
};

template <typename T>
struct remove_const<const T>
{
    typedef T type;
};

template <typename T>
struct remove_volatile
{
    typedef T type;
};

template <typename T>
struct remove_volatile<volatile T>
{
    typedef T type;
};

template <typename T>
struct remove_cv : remove_const<typename remove_volatile<T>::type>
{
};

template <typename T>
struct remove_reference
{
    typedef T type;
};

template <typename T>
struct remove_reference<T&>
{
    typedef T type;
};

template <typename T>
struct remove_reference<T&&>
{
    typedef T type;
};

template <typename T>
struct is_lvalue_reference
{
    enum { value = false };
};

template <typename T>
struct is_lvalue_reference<T&>
{
    enum { value = true };
};

template <typename T>
struct is_unqualified_pointer
{
    enum { value = false };
};

template <typename T>
struct is_unqualified_pointer<T*>
{
    enum { value = true };
};

template <typename T>
struct is_pointer : is_unqualified_pointer<typename remove_cv<T>::type>
{
};

template <typename T>
struct is_integral
{
    enum { value = false };
};

template<>
struct is_integral<bool>
{
    enum { value = true };
};

template<>
struct is_integral<char>
{
    enum { value = true };
};

template<>
struct is_integral<unsigned char>
{
    enum { value = true };
};

template<>
struct is_integral<signed char>
{
    enum { value = true };
};

template<>
struct is_integral<unsigned short>
{
    enum { value = true };
};

template<>
struct is_integral<signed short>
{
    enum { value = true };
};

template<>
struct is_integral<unsigned int>
{
    enum { value = true };
};

template<>
struct is_integral<signed int>
{
    enum { value = true };
};

template<>
struct is_integral<unsigned __int64>
{
    enum { value = true };
};

template<>
struct is_integral<signed __int64>
{
    enum { value = true };
};


template<bool Pred, typename Type1, typename Type2>
struct conditional
{
};

template<typename Type1, typename Type2>
struct conditional<true, Type1, Type2>
{
    typedef Type1 type;
};

template<typename Type1, typename Type2>
struct conditional<false, Type1, Type2>
{
    typedef Type2 type;
};

template<typename Type1>
struct make_unsigned
{
};

template<>
struct make_unsigned<int>
{
    typedef unsigned int type;
};

#ifndef _HOST_UNIX_

template<>
struct make_unsigned<long>
{
    typedef unsigned long type;
};

#endif // !_HOST_UNIX_

template<>
struct make_unsigned<__int64>
{
    typedef unsigned __int64 type;
};

} // namespace jit_std