Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_meta_cat.h
Go to the documentation of this file.
1
30#ifndef _RWSTD_RW_META_CAT_H_INCLUDED
31#define _RWSTD_RW_META_CAT_H_INCLUDED
32
33#include <rw/_defs.h>
34#include <rw/_meta_help.h>
35
37
38#define _RWSTD_TRAIT_SPEC_0_CV(Trait,Type,Cond) \
39 template <> struct Trait<Type> \
40 : __rw_integral_constant<bool, Cond> { }; \
41 template <> struct Trait<Type const> \
42 : __rw_integral_constant<bool, Cond> { }; \
43 template <> struct Trait<Type volatile> \
44 : __rw_integral_constant<bool, Cond> { }; \
45 template <> struct Trait<Type const volatile> \
46 : __rw_integral_constant<bool, Cond> { }
47
48#define _RWSTD_TRAIT_SPEC_1_CV(Trait,Type,Cond) \
49 template <class _TypeT> struct Trait<Type> \
50 : __rw_integral_constant<bool, Cond> { }; \
51 template <class _TypeT> struct Trait<Type const> \
52 : __rw_integral_constant<bool, Cond> { }; \
53 template <class _TypeT> struct Trait<Type volatile> \
54 : __rw_integral_constant<bool, Cond> { }; \
55 template <class _TypeT> struct Trait<Type const volatile> \
56 : __rw_integral_constant<bool, Cond> { }
57
58#define _RWSTD_TRAIT_SPEC_2_CV(Trait,Type,Cond) \
59 template <class _TypeT, class _ClassT> struct Trait<Type> \
60 : __rw_integral_constant<bool, Cond> { }; \
61 template <class _TypeT, class _ClassT> struct Trait<Type const> \
62 : __rw_integral_constant<bool, Cond> { }; \
63 template <class _TypeT, class _ClassT> struct Trait<Type volatile> \
64 : __rw_integral_constant<bool, Cond> { }; \
65 template <class _TypeT, class _ClassT> \
66 struct Trait<Type const volatile> \
67 : __rw_integral_constant<bool, Cond> { }
68
69template <class _TypeT>
70struct __rw_is_void : __rw_false_type
71{
72};
73
74_RWSTD_TRAIT_SPEC_0_CV(__rw_is_void, void, true);
75
76#define _RWSTD_IS_VOID(T) _RW::__rw_is_void<T>::value
77
78
79template <class _TypeT>
80struct __rw_is_integral : __rw_false_type
81{
82};
83
84_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, bool, true);
85_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, char, true);
86
87#if 0
88_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, char16_t, true);
89_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, char32_t, true);
90#endif // 0
91
92#ifndef _RWSTD_NO_NATIVE_WCHAR_T
93_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, wchar_t, true);
94#endif // _RWSTD_NO_NATIVE_WCHAR_T
95
96_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, signed char, true);
97_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, unsigned char, true);
98_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, signed short, true);
99_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, unsigned short, true);
100_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, signed int, true);
101_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, unsigned int, true);
102_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, signed long, true);
103_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, unsigned long, true);
104
105#ifndef _RWSTD_NO_LONG_LONG
106_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, signed long long, true);
107_RWSTD_TRAIT_SPEC_0_CV(__rw_is_integral, unsigned long long, true);
108#endif // _RWSTD_NO_LONG_LONG
109
110#define _RWSTD_IS_INTEGRAL(T) _RW::__rw_is_integral<T>::value
111
112template <class _TypeT>
113struct __rw_is_floating_point : __rw_false_type
114{
115};
116
117_RWSTD_TRAIT_SPEC_0_CV(__rw_is_floating_point, float, true);
118_RWSTD_TRAIT_SPEC_0_CV(__rw_is_floating_point, double, true);
119
120#ifndef _RWSTD_NO_LONG_DOUBLE
121_RWSTD_TRAIT_SPEC_0_CV(__rw_is_floating_point, long double, true);
122#endif // _RWSTD_NO_LONG_DOUBLE
123
124#define _RWSTD_IS_FLOATING_POINT(T) _RW::__rw_is_floating_point<T>::value
125
126
127template <class _TypeT>
128struct __rw_is_array : __rw_false_type
129{
130};
131
132template <class _TypeT, _RWSTD_SIZE_T _Size>
133struct __rw_is_array<_TypeT [_Size]> : __rw_true_type
134{
135};
136
137#if !defined (__IBMCPP__) || (900 < __IBMCPP__)
138
139template <class _TypeT>
140struct __rw_is_array<_TypeT []> : __rw_true_type
141{
142};
143
144#endif
145
146#define _RWSTD_IS_ARRAY(T) _RW::__rw_is_array<T>::value
147
148template <class _TypeT>
149struct __rw_is_pointer : __rw_false_type
150{
151};
152
153_RWSTD_TRAIT_SPEC_1_CV(__rw_is_pointer, _TypeT*, true);
154
155#define _RWSTD_IS_POINTER(T) _RW::__rw_is_pointer<T>::value
156
157
158template <class _TypeT>
159struct __rw_is_lvalue_reference : __rw_false_type
160{
161};
162
163template <class _TypeT>
164struct __rw_is_lvalue_reference<_TypeT&> : __rw_true_type
165{
166};
167
168#define _RWSTD_IS_LVALUE_REFERENCE(T) \
169 _RW::__rw_is_lvalue_reference<T>::value
170
171
172template <class _TypeT>
173struct __rw_is_rvalue_reference : __rw_false_type
174{
175};
176
177
178#ifndef _RWSTD_NO_RVALUE_REFERENCES
179
180template <class _TypeT>
181struct __rw_is_rvalue_reference<_TypeT&&> : __rw_true_type
182{
183};
184
185#endif // _RWSTD_NO_RVALUE_REFERENCES
186
187#define _RWSTD_IS_RVALUE_REFERENCE(T) \
188 _RW::__rw_is_rvalue_reference<T>::value
189
190
191
192template <class _TypeT>
193struct __rw_is_class_or_union
194{
195 struct _C_no { };
196 struct _C_yes { _C_no __pad[2]; };
197
198 template <class _TypeU>
199 static _C_yes _C_is (int, long _TypeU::*);
200
201 template <class _TypeU>
202 static _C_no _C_is (int, ...);
203
204 enum { value =
205 sizeof (_C_yes) == sizeof (_C_is<_TypeT>(0, 0))
206 };
207};
208
209#if defined (_RWSTD_TT_IS_UNION)
210# define _RWSTD_IS_UNION(T) _RWSTD_TT_IS_UNION(T)
211#elif defined (_RWSTD_TT_IS_CLASS)
212# define _RWSTD_IS_UNION(T) \
213 _RW::__rw_is_class_or_union<T>::value && !_RWSTD_TT_IS_CLASS(T)
214#else
215# define _RWSTD_IS_UNION(T) 0
216#endif
217
218template <class _TypeT>
219struct __rw_is_union
220 : __rw_integral_constant<bool, _RWSTD_IS_UNION(_TypeT)>
221{
222};
223
224
225#if defined (_RWSTD_TT_IS_CLASS)
226# define _RWSTD_IS_CLASS(T) _RWSTD_TT_IS_CLASS(T)
227#elif defined (_RWSTD_TT_IS_UNION)
228# define _RWSTD_IS_CLASS(T) \
229 _RW::__rw_is_class_or_union<T>::value && !_RWSTD_TT_IS_UNION(T)
230#else
231# define _RWSTD_IS_CLASS(T) _RW::__rw_is_class_or_union<T>::value
232#endif
233
234template <class _TypeT>
235struct __rw_is_class
236 : __rw_integral_constant<bool, _RWSTD_IS_CLASS(_TypeT)>
237{
238};
239
240
241
242#ifdef _RWSTD_TT_IS_ENUM
243# define _RWSTD_IS_ENUM(T) _RWSTD_TT_IS_ENUM(T)
244#else
245
246template <class _TypeT, bool = __rw_is_void<_TypeT>::value
247 || __rw_is_array<_TypeT>::value
248 || __rw_is_integral<_TypeT>::value
249 || __rw_is_floating_point<_TypeT>::value
250 || __rw_is_lvalue_reference<_TypeT>::value
251 || __rw_is_rvalue_reference<_TypeT>::value
252 || __rw_is_class_or_union<_TypeT>::value>
253struct __rw_is_enum_impl
254{
255 enum { _C_value = 0 };
256};
257
258template <class _TypeT>
259struct __rw_is_enum_impl<_TypeT, false>
260{
261 struct _C_no { };
262 struct _C_yes { _C_no __pad [2]; };
263
264 // supply first argument to prevent HP aCC warnings
265 static _C_no _C_is (int, ...);
266 static _C_yes _C_is (int, double);
267
268 static _TypeT& _C_make ();
269
270 enum {
271 _C_value = sizeof (_C_yes) == sizeof (_C_is (0, _C_make ()))
272 };
273};
274
275# define _RWSTD_IS_ENUM(T) _RW::__rw_is_enum_impl<T>::_C_value
276#endif // !_RWSTD_TT_IS_ENUM
277
278template <class _TypeT>
279struct __rw_is_enum
280 : __rw_integral_constant<bool, _RWSTD_IS_ENUM(_TypeT)>
281{
282};
283
284
285
286#ifdef _RWSTD_TT_IS_FUNCTION
287# define _RWSTD_IS_FUNCTION(T) _RWSTD_TT_IS_FUNCTION(T)
288#else
289
290//
291// This template prevents the partial specialization below from
292// being instantiated on types for which it would fail or give
293// invalid results. i.e. it avoids creating references to void or
294// arrays with unknown length and for returning bad results for
295// references to functions.
296//
297template <class _TypeT, bool = __rw_is_void<_TypeT>::value
298 || __rw_is_array<_TypeT>::value
299 || __rw_is_pointer<_TypeT>::value
300 || __rw_is_lvalue_reference<_TypeT>::value
301 || __rw_is_rvalue_reference<_TypeT>::value
302 || __rw_is_class_or_union<_TypeT>::value>
303struct __rw_is_function_impl
304{
305 enum { _C_value = 0 };
306};
307
308//
309// This specialization determines if _TypeT is a function type. This
310// is done by testing that a _TypeT is implicitly convertible to a
311// pointer to _TypeT. This special case is only true for functions
312// and member functions.
313//
314template <class _TypeT>
315struct __rw_is_function_impl<_TypeT, false>
316{
317 typedef _TypeT& _TypeT_Ref;
318 typedef _TypeT* _TypeT_Ptr;
319
320 struct _C_no { };
321 struct _C_yes { _C_no __pad [2]; };
322
323 static _C_yes _C_is (_TypeT_Ptr);
324
325 template <class _TypeU>
326 static _C_no _C_is (_TypeU);
327
328 static _TypeT_Ref _C_make ();
329
330 enum { _C_value = sizeof (_C_yes) == sizeof (_C_is (_C_make ())) };
331};
332
333# define _RWSTD_IS_FUNCTION(T) _RW::__rw_is_function_impl<T>::_C_value
334#endif //_RWSTD_TT_IS_FUNCTION
335
336template <class _TypeT>
337struct __rw_is_function
338 : __rw_integral_constant<bool, _RWSTD_IS_FUNCTION(_TypeT)>
339{
340};
341
342
343template <class _TypeT>
344struct __rw_is_member_object_pointer : __rw_false_type
345{
346};
347
348_RWSTD_TRAIT_SPEC_2_CV(__rw_is_member_object_pointer,
349 _TypeT _ClassT::*,
350 !__rw_is_function<_TypeT>::value);
351
352#define _RWSTD_IS_MEMBER_OBJECT_PTR(T) \
353 _RW::__rw_is_member_object_pointer<T>::value
354
355
356template <class _TypeT>
357struct __rw_is_member_function_pointer : __rw_false_type
358{
359};
360
361_RWSTD_TRAIT_SPEC_2_CV(__rw_is_member_function_pointer,
362 _TypeT _ClassT::*,
363 __rw_is_function<_TypeT>::value);
364
365#define _RWSTD_IS_MEMBER_FUNCTION_PTR(T) \
366 _RW::__rw_is_member_function_pointer<T>::value
367
368#undef _RWSTD_TRAIT_SPEC_2_CV
369#undef _RWSTD_TRAIT_SPEC_1_CV
370#undef _RWSTD_TRAIT_SPEC_0_CV
371
372} // namespace __rw
373
374
375#endif // _RWSTD_RW_META_CAT_H_INCLUDED
376
T value(const T &val)
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_TRAIT_SPEC_1_CV(Trait, Type, Cond)
#define _RWSTD_TRAIT_SPEC_2_CV(Trait, Type, Cond)
#define _RWSTD_TRAIT_SPEC_0_CV(Trait, Type, Cond)
#define false
Definition stdbool.h:26