A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
type-traits.h
Go to the documentation of this file.
1
#ifndef TYPE_TRAITS_H
2
#define TYPE_TRAITS_H
3
5
template
<
typename
T>
6
struct
TypeTraits
7
{
8
private
:
9
struct
NullType
{};
10
template
<
typename
U>
struct
UnConst
11
{
12
typedef
U
Result
;
13
};
14
template
<
typename
U>
struct
UnConst
<const U>
15
{
16
typedef
U
Result
;
17
};
18
template
<
typename
U>
struct
ReferenceTraits
19
{
20
enum
{
IsReference
= 0 };
21
typedef
U
ReferencedType
;
22
};
23
template
<
typename
U>
struct
ReferenceTraits
<U&>
24
{
25
enum
{
IsReference
= 1 };
26
typedef
U
ReferencedType
;
27
};
28
template
<
typename
U>
struct
PointerTraits
29
{
30
enum
{
IsPointer
= 0};
31
typedef
U
PointeeType
;
32
};
33
template
<
typename
U>
struct
PointerTraits
<U *>
34
{
35
enum
{
IsPointer
= 1};
36
typedef
U
PointeeType
;
37
};
38
template
<
typename
U>
struct
FunctionPtrTraits
39
{
40
enum
{
IsFunctionPointer
= 0};
41
typedef
NullType
ReturnType
;
42
};
43
template
<
typename
U>
44
struct
FunctionPtrTraits
<U (*)(
void
)>
45
{
46
enum
{
IsFunctionPointer
= 1};
47
enum
{ nArgs = 0};
48
typedef
U
ReturnType
;
49
};
50
template
<
typename
U,
typename
V1>
51
struct
FunctionPtrTraits
<U (*)(V1)>
52
{
53
enum
{
IsFunctionPointer
= 1};
54
enum
{ nArgs = 1};
55
typedef
U
ReturnType
;
56
typedef
V1
Arg1Type
;
57
};
58
template
<
typename
U,
typename
V1,
typename
V2>
59
struct
FunctionPtrTraits
<U (*)(V1,V2)>
60
{
61
enum
{
IsFunctionPointer
= 1};
62
enum
{ nArgs = 2};
63
typedef
U
ReturnType
;
64
typedef
V1
Arg1Type
;
65
typedef
V2
Arg2Type
;
66
};
67
template
<
typename
U,
typename
V1,
typename
V2,
68
typename
V3>
69
struct
FunctionPtrTraits
<U (*)(V1,V2,V3)>
70
{
71
enum
{
IsFunctionPointer
= 1};
72
enum
{ nArgs = 3};
73
typedef
U
ReturnType
;
74
typedef
V1
Arg1Type
;
75
typedef
V2
Arg2Type
;
76
typedef
V3
Arg3Type
;
77
};
78
template
<
typename
U,
typename
V1,
typename
V2,
79
typename
V3,
typename
V4>
80
struct
FunctionPtrTraits
<U (*)(V1,V2,V3,V4)>
81
{
82
enum
{
IsFunctionPointer
= 1};
83
enum
{ nArgs = 4};
84
typedef
U
ReturnType
;
85
typedef
V1
Arg1Type
;
86
typedef
V2
Arg2Type
;
87
typedef
V3
Arg3Type
;
88
typedef
V4
Arg4Type
;
89
};
90
template
<
typename
U,
typename
V1,
typename
V2,
91
typename
V3,
typename
V4,
92
typename
V5>
93
struct
FunctionPtrTraits
<U (*)(V1,V2,V3,V4,V5)>
94
{
95
enum
{
IsFunctionPointer
= 1};
96
enum
{ nArgs = 5};
97
typedef
U
ReturnType
;
98
typedef
V1
Arg1Type
;
99
typedef
V2
Arg2Type
;
100
typedef
V3
Arg3Type
;
101
typedef
V4
Arg4Type
;
102
typedef
V5
Arg5Type
;
103
};
104
template
<
typename
U,
typename
V1,
typename
V2,
105
typename
V3,
typename
V4,
106
typename
V5,
typename
V6>
107
struct
FunctionPtrTraits
<U (*)(V1,V2,V3,V4,V5,V6)>
108
{
109
enum
{
IsFunctionPointer
= 1};
110
enum
{ nArgs = 6};
111
typedef
U
ReturnType
;
112
typedef
V1
Arg1Type
;
113
typedef
V2
Arg2Type
;
114
typedef
V3
Arg3Type
;
115
typedef
V4
Arg4Type
;
116
typedef
V5
Arg5Type
;
117
typedef
V6
Arg6Type
;
118
};
119
template
<
typename
U>
struct
PtrToMemberTraits
120
{
121
enum
{
IsPointerToMember
= 0};
122
};
123
template
<
typename
U,
typename
V>
124
struct
PtrToMemberTraits
<U (
V
::*) (void)>
125
{
126
enum
{
IsPointerToMember
= 1};
127
enum
{ nArgs = 0};
128
typedef
U
ReturnType
;
129
};
130
template
<
typename
U,
typename
V>
131
struct
PtrToMemberTraits
<U (
V
::*) (void) const>
132
{
133
enum
{
IsPointerToMember
= 1};
134
enum
{ nArgs = 0};
135
typedef
U
ReturnType
;
136
};
137
template
<
typename
U,
typename
V,
typename
W1>
138
struct
PtrToMemberTraits
<U (
V
::*) (W1)>
139
{
140
enum
{
IsPointerToMember
= 1};
141
enum
{ nArgs = 1};
142
typedef
U
ReturnType
;
143
typedef
W1
Arg1Type
;
144
};
145
template
<
typename
U,
typename
V,
typename
W1>
146
struct
PtrToMemberTraits
<U (
V
::*) (W1) const>
147
{
148
enum
{
IsPointerToMember
= 1};
149
enum
{ nArgs = 1};
150
typedef
U
ReturnType
;
151
typedef
W1
Arg1Type
;
152
};
153
template
<
typename
U,
typename
V,
typename
W1,
typename
W2>
154
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2)>
155
{
156
enum
{
IsPointerToMember
= 1};
157
enum
{ nArgs = 2};
158
typedef
U
ReturnType
;
159
typedef
W1
Arg1Type
;
160
typedef
W2
Arg2Type
;
161
};
162
template
<
typename
U,
typename
V,
typename
W1,
typename
W2>
163
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2) const>
164
{
165
enum
{
IsPointerToMember
= 1};
166
enum
{ nArgs = 2};
167
typedef
U
ReturnType
;
168
typedef
W1
Arg1Type
;
169
typedef
W2
Arg2Type
;
170
};
171
template
<
typename
U,
typename
V
,
172
typename
W1,
typename
W2,
173
typename
W3>
174
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3)>
175
{
176
enum
{
IsPointerToMember
= 1};
177
enum
{ nArgs = 3};
178
typedef
U
ReturnType
;
179
typedef
W1
Arg1Type
;
180
typedef
W2
Arg2Type
;
181
typedef
W3
Arg3Type
;
182
};
183
template
<
typename
U,
typename
V
,
184
typename
W1,
typename
W2,
185
typename
W3>
186
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3) const>
187
{
188
enum
{
IsPointerToMember
= 1};
189
enum
{ nArgs = 3};
190
typedef
U
ReturnType
;
191
typedef
W1
Arg1Type
;
192
typedef
W2
Arg2Type
;
193
typedef
W3
Arg3Type
;
194
};
195
template
<
typename
U,
typename
V
,
196
typename
W1,
typename
W2,
197
typename
W3,
typename
W4>
198
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3,W4)>
199
{
200
enum
{
IsPointerToMember
= 1};
201
enum
{ nArgs = 4};
202
typedef
U
ReturnType
;
203
typedef
W1
Arg1Type
;
204
typedef
W2
Arg2Type
;
205
typedef
W3
Arg3Type
;
206
typedef
W4
Arg4Type
;
207
};
208
template
<
typename
U,
typename
V
,
209
typename
W1,
typename
W2,
210
typename
W3,
typename
W4>
211
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3,W4) const>
212
{
213
enum
{
IsPointerToMember
= 1};
214
enum
{ nArgs = 4};
215
typedef
U
ReturnType
;
216
typedef
W1
Arg1Type
;
217
typedef
W2
Arg2Type
;
218
typedef
W3
Arg3Type
;
219
typedef
W4
Arg4Type
;
220
};
221
template
<
typename
U,
typename
V
,
222
typename
W1,
typename
W2,
223
typename
W3,
typename
W4,
224
typename
W5>
225
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3,W4,W5)>
226
{
227
enum
{
IsPointerToMember
= 1};
228
enum
{ nArgs = 5};
229
typedef
U
ReturnType
;
230
typedef
W1
Arg1Type
;
231
typedef
W2
Arg2Type
;
232
typedef
W3
Arg3Type
;
233
typedef
W4
Arg4Type
;
234
typedef
W5
Arg5Type
;
235
};
236
template
<
typename
U,
typename
V
,
237
typename
W1,
typename
W2,
238
typename
W3,
typename
W4,
239
typename
W5>
240
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3,W4,W5) const>
241
{
242
enum
{
IsPointerToMember
= 1};
243
enum
{ nArgs = 5};
244
typedef
U
ReturnType
;
245
typedef
W1
Arg1Type
;
246
typedef
W2
Arg2Type
;
247
typedef
W3
Arg3Type
;
248
typedef
W4
Arg4Type
;
249
typedef
W5
Arg5Type
;
250
};
251
template
<
typename
U,
typename
V
,
252
typename
W1,
typename
W2,
253
typename
W3,
typename
W4,
254
typename
W5,
typename
W6>
255
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3,W4,W5,W6)>
256
{
257
enum
{
IsPointerToMember
= 1};
258
enum
{ nArgs = 6};
259
typedef
U
ReturnType
;
260
typedef
W1
Arg1Type
;
261
typedef
W2
Arg2Type
;
262
typedef
W3
Arg3Type
;
263
typedef
W4
Arg4Type
;
264
typedef
W5
Arg5Type
;
265
typedef
W6
Arg6Type
;
266
};
267
template
<
typename
U,
typename
V
,
268
typename
W1,
typename
W2,
269
typename
W3,
typename
W4,
270
typename
W5,
typename
W6>
271
struct
PtrToMemberTraits
<U (
V
::*) (W1,W2,W3,W4,W5,W6) const>
272
{
273
enum
{
IsPointerToMember
= 1};
274
enum
{ nArgs = 6};
275
typedef
U
ReturnType
;
276
typedef
W1
Arg1Type
;
277
typedef
W2
Arg2Type
;
278
typedef
W3
Arg3Type
;
279
typedef
W4
Arg4Type
;
280
typedef
W5
Arg5Type
;
281
typedef
W6
Arg6Type
;
282
};
283
284
public
:
285
typedef
typename
UnConst<T>::Result
NonConstType
;
286
typedef
typename
ReferenceTraits<T>::ReferencedType
ReferencedType
;
287
typedef
typename
PointerTraits<T>::PointeeType
PointeeType
;
288
enum
{
IsPointerToMember
= PtrToMemberTraits<T>::IsPointerToMember};
289
enum
{
IsPointer
= PointerTraits<T>::IsPointer};
290
enum
{
IsReference
= ReferenceTraits<T>::IsReference};
291
enum
{
IsFunctionPointer
= FunctionPtrTraits<T>::IsFunctionPointer};
292
typedef
PtrToMemberTraits<T>
PointerToMemberTraits
;
293
typedef
FunctionPtrTraits<T>
FunctionPointerTraits
;
294
};
295
296
297
#endif
/* TYPE_TRAITS_H */
src
core
model
type-traits.h
Generated on Fri Aug 30 2013 01:42:47 for ns-3 by
1.8.1.2