Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_meta_sign.h
Go to the documentation of this file.
1
30#ifndef _RWSTD_RW_META_SIGN_H_INCLUDED
31#define _RWSTD_RW_META_SIGN_H_INCLUDED
32
33#include <rw/_defs.h>
34#include <rw/_meta_other.h>
35#include <rw/_meta_rel.h>
36#include <rw/_meta_cv.h>
37#include <rw/_static_assert.h>
38
40
41// Provides typedefs mapping non-boolean integral types to signed
42// and unsigned integral types of the same base type.
43template <class _TypeT>
44struct __rw_sign_helper
45{
46 typedef void _C_Sint;
47 typedef void _C_Uint;
48};
49
50template <>
51struct __rw_sign_helper<char>
52{
53#if (_RWSTD_CHAR_MIN < 0)
54 typedef char _C_Sint;
55 typedef unsigned char _C_Uint;
56#else
57 typedef signed char _C_Sint;
58 typedef char _C_Uint;
59#endif
60};
61
62#ifndef _RWSTD_NO_NATIVE_WCHAR_T
63
64template <>
65struct __rw_sign_helper<wchar_t>
66{
67#if (_RWSTD_WCHAR_MIN < 0)
68 typedef wchar_t _C_Sint;
69
70# if (_RWSTD_WCHAR_SIZE == _RWSTD_CHAR_SIZE)
71 typedef unsigned char _C_Uint;
72# elif (_RWSTD_WCHAR_SIZE == _RWSTD_SHRT_SIZE)
73 typedef unsigned short _C_Uint;
74# elif (_RWSTD_WCHAR_SIZE == _RWSTD_INT_SIZE)
75 typedef unsigned int _C_Uint;
76# elif (_RWSTD_WCHAR_SIZE == _RWSTD_LONG_SIZE)
77 typedef unsigned long _C_Uint;
78# elif (_RWSTD_WCHAR_SIZE == _RWSTD_LLONG_SIZE)
79 typedef unsigned long long _C_Uint;
80# endif
81
82# else // 0 <= _RWSTD_WCHAR_MIN
83
84# if (_RWSTD_WCHAR_SIZE == _RWSTD_CHAR_SIZE)
85 typedef signed char _C_Sint;
86# elif (_RWSTD_WCHAR_SIZE == _RWSTD_SHRT_SIZE)
87 typedef signed short _C_Sint;
88# elif (_RWSTD_WCHAR_SIZE == _RWSTD_INT_SIZE)
89 typedef signed int _C_Sint;
90# elif (_RWSTD_WCHAR_SIZE == _RWSTD_LONG_SIZE)
91 typedef signed long _C_Sint;
92# elif (_RWSTD_WCHAR_SIZE == _RWSTD_LLONG_SIZE)
93 typedef signed long long _C_Sint;
94# endif
95
96 typedef wchar_t _C_Uint;
97# endif // 0 <= _RWSTD_WCHAR_MIN
98};
99
100#endif // _RWSTD_NO_NATIVE_WCHAR_T
101
102template <>
103struct __rw_sign_helper<signed char>
104{
105 typedef signed char _C_Sint;
106 typedef unsigned char _C_Uint;
107};
108
109template <>
110struct __rw_sign_helper<unsigned char>
111{
112 typedef signed char _C_Sint;
113 typedef unsigned char _C_Uint;
114};
115
116template <>
117struct __rw_sign_helper<signed short>
118{
119 typedef signed short _C_Sint;
120 typedef unsigned short _C_Uint;
121};
122
123template <>
124struct __rw_sign_helper<unsigned short>
125{
126 typedef signed short _C_Sint;
127 typedef unsigned short _C_Uint;
128};
129
130template <>
131struct __rw_sign_helper<signed int>
132{
133 typedef signed int _C_Sint;
134 typedef unsigned int _C_Uint;
135};
136
137template <>
138struct __rw_sign_helper<unsigned int>
139{
140 typedef signed int _C_Sint;
141 typedef unsigned int _C_Uint;
142};
143
144template <>
145struct __rw_sign_helper<signed long>
146{
147 typedef signed long _C_Sint;
148 typedef unsigned long _C_Uint;
149};
150
151template <>
152struct __rw_sign_helper<unsigned long>
153{
154 typedef signed long _C_Sint;
155 typedef unsigned long _C_Uint;
156};
157
158
159#ifndef _RWSTD_NO_LONG_LONG
160
161template <>
162struct __rw_sign_helper<signed long long>
163{
164 typedef signed long long _C_Sint;
165 typedef unsigned long long _C_Uint;
166};
167
168template <>
169struct __rw_sign_helper<unsigned long long>
170{
171 typedef signed long long _C_Sint;
172 typedef unsigned long long _C_Uint;
173};
174
175#endif // !_RWSTD_NO_LONG_LONG
176
177
178// Class template provides typedefs mapping enumeration types
179// to integral types of the same size.
180template <_RWSTD_SIZE_T _Size>
181struct __rw_enum_helper
182{
183 typedef void _C_Sint;
184 typedef void _C_Uint;
185};
186
187template <>
188struct __rw_enum_helper<_RWSTD_CHAR_SIZE>
189{
190 typedef signed char _C_Sint;
191 typedef unsigned char _C_Uint;
192};
193
194template <>
195struct __rw_enum_helper<_RWSTD_SHRT_SIZE>
196{
197 typedef signed short _C_Sint;
198 typedef unsigned short _C_Uint;
199};
200
201template <>
202struct __rw_enum_helper<_RWSTD_INT_SIZE>
203{
204 typedef signed int _C_Sint;
205 typedef unsigned int _C_Uint;
206};
207
208#if (_RWSTD_INT_SIZE != _RWSTD_LONG_SIZE)
209
210template <>
211struct __rw_enum_helper<_RWSTD_LONG_SIZE>
212{
213 typedef signed long _C_Sint;
214 typedef unsigned long _C_Uint;
215};
216
217#endif // (_RWSTD_INT_SIZE != _RWSTD_LONG_SIZE)
218
219#ifndef _RWSTD_NO_LONG_LONG
220# if (_RWSTD_LONG_SIZE != _RWSTD_LLONG_SIZE)
221
222template <>
223struct __rw_enum_helper<_RWSTD_LLONG_SIZE>
224{
225 typedef signed long long _C_Sint;
226 typedef unsigned long long _C_Uint;
227};
228
229# endif // _RWSTD_LONG_SIZE != _RWSTD_LLONG_SIZE
230#endif // !_RWSTD_NO_LONG_LONG
231
232template <class _TypeT>
233struct __rw_make_signed
234{
235private:
236 //_RWSTD_STATIC_ASSERT ( __rw_is_integral<_TypeT>::value
237 // || __rw_is_enum<_TypeT>::value);
238
239 typedef typename __rw_remove_cv<_TypeT>::type _NoCV_TypeT;
240
241 //_RWSTD_STATIC_ASSERT (!__rw_is_same<_NoCV_TypeT, bool>::value);
242
243 typedef typename
244 __rw_conditional<__rw_is_integral<_NoCV_TypeT>::value,
245 typename __rw_sign_helper<_NoCV_TypeT>::_C_Sint,
246 typename __rw_enum_helper< sizeof (_TypeT) >::_C_Sint
247 >::type _NoCV_TypeU;
248
249 typedef typename
250 __rw_conditional<__rw_is_const<_TypeT>::value,
251 typename __rw_add_const<_NoCV_TypeU>::type,
252 _NoCV_TypeU>::type _NoV_TypeU;
253
254 typedef typename
255 __rw_conditional<__rw_is_volatile<_TypeT>::value,
256 typename __rw_add_volatile<_NoV_TypeU>::type,
257 _NoV_TypeU>::type _TypeU;
258
259public:
260 typedef _TypeU type;
261};
262
263#define _RWSTD_MAKE_SIGNED(T) _RW::__rw_make_signed<T>::type
264
265template <class _TypeT>
266struct __rw_make_unsigned
267{
268private:
269 //_RWSTD_STATIC_ASSERT ( __rw_is_integral<_TypeT>::value
270 // || __rw_is_enum<_TypeT>::value);
271
272 typedef typename __rw_remove_cv<_TypeT>::type _NoCV_TypeT;
273
274 //_RWSTD_STATIC_ASSERT (!__rw_is_same<_NoCV_TypeT, bool>::value);
275
276 typedef typename
277 __rw_conditional<__rw_is_integral<_NoCV_TypeT>::value,
278 typename __rw_sign_helper<_NoCV_TypeT>::_C_Uint,
279 typename __rw_enum_helper< sizeof (_TypeT) >::_C_Uint
280 >::type _NoCV_TypeU;
281
282 typedef typename
283 __rw_conditional<__rw_is_const<_TypeT>::value,
284 typename __rw_add_const<_NoCV_TypeU>::type,
285 _NoCV_TypeU>::type _NoV_TypeU;
286
287 typedef typename
288 __rw_conditional<__rw_is_volatile<_TypeT>::value,
289 typename __rw_add_volatile<_NoV_TypeU>::type,
290 _NoV_TypeU>::type _TypeU;
291
292public:
293 typedef _TypeU type;
294};
295
296#define _RWSTD_MAKE_UNSIGNED(T) _RW::__rw_make_unsigned<T>::type
297
298} // namespace __rw
299
300
301#endif // _RWSTD_RW_META_SIGN_H_INCLUDED
302
unsigned short wchar_t
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567