31#ifndef ETL_INTEGRAL_LIMITS_INCLUDED
32#define ETL_INTEGRAL_LIMITS_INCLUDED
50 #define LLONG_MAX 9223372036854775807LL
54 #define LLONG_MIN (-LLONG_MAX - 1LL)
58 #define ULLONG_MAX 18446744073709551615ULL
63 namespace private_integral_limits
77 template <
typename T =
void>
80 typedef signed char value_type;
82 static ETL_CONSTANT
signed char min = SCHAR_MIN;
83 static ETL_CONSTANT
signed char max = SCHAR_MAX;
84 static ETL_CONSTANT
int bits = CHAR_BIT;
85 static ETL_CONSTANT
bool is_signed = etl::is_signed<signed char>::value;
89 ETL_CONSTANT
signed char statics_signed_char<T>::min;
92 ETL_CONSTANT
signed char statics_signed_char<T>::max;
95 ETL_CONSTANT
int statics_signed_char<T>::bits;
98 ETL_CONSTANT
bool statics_signed_char<T>::is_signed;
102 template <
typename T =
void>
105 typedef unsigned char value_type;
107 static ETL_CONSTANT
unsigned char min = 0;
108 static ETL_CONSTANT
unsigned char max = UCHAR_MAX;
109 static ETL_CONSTANT
int bits = CHAR_BIT;
110 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned char>::value;
113 template <
typename T>
114 ETL_CONSTANT
unsigned char statics_unsigned_char<T>::min;
116 template <
typename T>
117 ETL_CONSTANT
unsigned char statics_unsigned_char<T>::max;
119 template <
typename T>
120 ETL_CONSTANT
int statics_unsigned_char<T>::bits;
122 template <
typename T>
123 ETL_CONSTANT
bool statics_unsigned_char<T>::is_signed;
127 template <
typename T =
void>
130 typedef char value_type;
132 static ETL_CONSTANT
char min = (etl::is_signed<char>::value) ? SCHAR_MIN : 0;
133 static ETL_CONSTANT
char max = (etl::is_signed<char>::value) ? SCHAR_MAX :
static_cast<char>(UCHAR_MAX);
134 static ETL_CONSTANT
int bits = CHAR_BIT;
135 static ETL_CONSTANT
bool is_signed = etl::is_signed<char>::value;
138 template <
typename T>
139 ETL_CONSTANT
char statics_char<T>::min;
141 template <
typename T>
142 ETL_CONSTANT
char statics_char<T>::max;
144 template <
typename T>
145 ETL_CONSTANT
int statics_char<T>::bits;
147 template <
typename T>
148 ETL_CONSTANT
bool statics_char<T>::is_signed;
152 template <
typename T =
void>
155 typedef wchar_t value_type;
157 static ETL_CONSTANT
wchar_t min = WCHAR_MIN;
158 static ETL_CONSTANT
wchar_t max = WCHAR_MAX;
159 static ETL_CONSTANT
int bits = CHAR_BIT *
sizeof(wchar_t);
160 static ETL_CONSTANT
bool is_signed = etl::is_signed<wchar_t>::value;
163 template <
typename T>
164 ETL_CONSTANT
wchar_t statics_wchar_t<T>::min;
166 template <
typename T>
167 ETL_CONSTANT
wchar_t statics_wchar_t<T>::max;
169 template <
typename T>
170 ETL_CONSTANT
int statics_wchar_t<T>::bits;
172 template <
typename T>
173 ETL_CONSTANT
bool statics_wchar_t<T>::is_signed;
177#if defined(ETL_COMPILER_MICROSOFT)
178 #pragma warning(push)
179 #pragma warning(disable : 4309)
182 template <
typename T =
void>
185 typedef short value_type;
187 static ETL_CONSTANT
short min = SHRT_MIN;
188 static ETL_CONSTANT
short max = SHRT_MAX;
189 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(short) /
sizeof(char));
190 static ETL_CONSTANT
bool is_signed = etl::is_signed<short>::value;
193 template <
typename T>
194 ETL_CONSTANT
short statics_short<T>::min;
196 template <
typename T>
197 ETL_CONSTANT
short statics_short<T>::max;
199 template <
typename T>
200 ETL_CONSTANT
int statics_short<T>::bits;
202 template <
typename T>
203 ETL_CONSTANT
bool statics_short<T>::is_signed;
205#if defined(ETL_COMPILER_MICROSOFT)
211 template <
typename T =
void>
214 typedef unsigned short value_type;
216 static ETL_CONSTANT
unsigned short min = 0;
217 static ETL_CONSTANT
unsigned short max = USHRT_MAX;
218 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned short) /
sizeof(char));
219 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned short>::value;
222 template <
typename T>
223 ETL_CONSTANT
unsigned short statics_unsigned_short<T>::min;
225 template <
typename T>
226 ETL_CONSTANT
unsigned short statics_unsigned_short<T>::max;
228 template <
typename T>
229 ETL_CONSTANT
int statics_unsigned_short<T>::bits;
231 template <
typename T>
232 ETL_CONSTANT
bool statics_unsigned_short<T>::is_signed;
236 template <
typename T =
void>
239 typedef int value_type;
241 static ETL_CONSTANT
int min = INT_MIN;
242 static ETL_CONSTANT
int max = INT_MAX;
243 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(int) /
sizeof(char));
244 static ETL_CONSTANT
bool is_signed = etl::is_signed<int>::value;
247 template <
typename T>
248 ETL_CONSTANT
int statics_int<T>::min;
250 template <
typename T>
251 ETL_CONSTANT
int statics_int<T>::max;
253 template <
typename T>
254 ETL_CONSTANT
int statics_int<T>::bits;
256 template <
typename T>
257 ETL_CONSTANT
bool statics_int<T>::is_signed;
261 template <
typename T =
void>
264 typedef unsigned int value_type;
266 static ETL_CONSTANT
unsigned int min = 0;
267 static ETL_CONSTANT
unsigned int max = UINT_MAX;
268 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned int) /
sizeof(char));
269 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned int>::value;
272 template <
typename T>
273 ETL_CONSTANT
unsigned int statics_unsigned_int<T>::min;
275 template <
typename T>
276 ETL_CONSTANT
unsigned int statics_unsigned_int<T>::max;
278 template <
typename T>
279 ETL_CONSTANT
int statics_unsigned_int<T>::bits;
281 template <
typename T>
282 ETL_CONSTANT
bool statics_unsigned_int<T>::is_signed;
286 template <
typename T =
void>
289 typedef long value_type;
291 static ETL_CONSTANT
long min = LONG_MIN;
292 static ETL_CONSTANT
long max = LONG_MAX;
293 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(long) /
sizeof(char));
294 static ETL_CONSTANT
bool is_signed = etl::is_signed<long>::value;
297 template <
typename T>
298 ETL_CONSTANT
long statics_long<T>::min;
300 template <
typename T>
301 ETL_CONSTANT
long statics_long<T>::max;
303 template <
typename T>
304 ETL_CONSTANT
int statics_long<T>::bits;
306 template <
typename T>
307 ETL_CONSTANT
bool statics_long<T>::is_signed;
311 template <
typename T =
void>
314 typedef unsigned long value_type;
316 static ETL_CONSTANT
unsigned long min = 0;
317 static ETL_CONSTANT
unsigned long max = ULONG_MAX;
318 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned long) /
sizeof(char));
319 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned long>::value;
322 template <
typename T>
323 ETL_CONSTANT
unsigned long statics_unsigned_long<T>::min;
325 template <
typename T>
326 ETL_CONSTANT
unsigned long statics_unsigned_long<T>::max;
328 template <
typename T>
329 ETL_CONSTANT
int statics_unsigned_long<T>::bits;
331 template <
typename T>
332 ETL_CONSTANT
bool statics_unsigned_long<T>::is_signed;
336 template <
typename T =
void>
339 typedef long long value_type;
341 static ETL_CONSTANT
long long min = LLONG_MIN;
342 static ETL_CONSTANT
long long max = LLONG_MAX;
343 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
long long) /
sizeof(char));
344 static ETL_CONSTANT
bool is_signed = etl::is_signed<long long>::value;
347 template <
typename T>
348 ETL_CONSTANT
long long statics_long_long<T>::min;
350 template <
typename T>
351 ETL_CONSTANT
long long statics_long_long<T>::max;
353 template <
typename T>
354 ETL_CONSTANT
int statics_long_long<T>::bits;
356 template <
typename T>
357 ETL_CONSTANT
bool statics_long_long<T>::is_signed;
361 template <
typename T =
void>
364 typedef unsigned long value_type;
366 static ETL_CONSTANT
unsigned long long min = 0;
367 static ETL_CONSTANT
unsigned long long max = ULLONG_MAX;
368 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned long long) /
sizeof(char));
369 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned long long>::value;
372 template <
typename T>
373 ETL_CONSTANT
unsigned long long statics_unsigned_long_long<T>::min;
375 template <
typename T>
376 ETL_CONSTANT
unsigned long long statics_unsigned_long_long<T>::max;
378 template <
typename T>
379 ETL_CONSTANT
int statics_unsigned_long_long<T>::bits;
381 template <
typename T>
382 ETL_CONSTANT
bool statics_unsigned_long_long<T>::is_signed;
384#if ETL_HAS_NATIVE_CHAR8_T
387 template <
typename T =
void>
388 struct statics_char8_t
392 static ETL_CONSTANT
char8_t min =
static_cast<char8_t>((etl::is_signed<char8_t>::value) ? SCHAR_MIN : 0);
393 static ETL_CONSTANT
char8_t max = (etl::is_signed<char8_t>::value) ?
static_cast<char8_t>(SCHAR_MAX) :
static_cast<char8_t>(UCHAR_MAX);
394 static ETL_CONSTANT
int bits = CHAR_BIT;
395 static ETL_CONSTANT
bool is_signed = etl::is_signed<char8_t>::value;
398 template <
typename T>
399 ETL_CONSTANT
char8_t statics_char8_t<T>::min;
401 template <
typename T>
402 ETL_CONSTANT
char8_t statics_char8_t<T>::max;
404 template <
typename T>
405 ETL_CONSTANT
int statics_char8_t<T>::bits;
407 template <
typename T>
408 ETL_CONSTANT
bool statics_char8_t<T>::is_signed;
411#if ETL_HAS_NATIVE_CHAR16_T
414 template <
typename T =
void>
415 struct statics_char16_t
419 static ETL_CONSTANT
char16_t min = 0;
420 static ETL_CONSTANT
char16_t max = 0xFFFFU;
421 static ETL_CONSTANT
int bits = 16;
422 static ETL_CONSTANT
bool is_signed =
false;
425 template <
typename T>
426 ETL_CONSTANT
char16_t statics_char16_t<T>::min;
428 template <
typename T>
429 ETL_CONSTANT
char16_t statics_char16_t<T>::max;
431 template <
typename T>
432 ETL_CONSTANT
int statics_char16_t<T>::bits;
434 template <
typename T>
435 ETL_CONSTANT
bool statics_char16_t<T>::is_signed;
438#if ETL_HAS_NATIVE_CHAR32_T
441 template <
typename T =
void>
442 struct statics_char32_t
444 typedef char32_t value_type;
446 static ETL_CONSTANT
char32_t min = 0;
447 static ETL_CONSTANT
char32_t max = 0xFFFFFFFFU;
448 static ETL_CONSTANT
int bits = 32;
449 static ETL_CONSTANT
bool is_signed =
false;
452 template <
typename T>
453 ETL_CONSTANT
char32_t statics_char32_t<T>::min;
455 template <
typename T>
456 ETL_CONSTANT
char32_t statics_char32_t<T>::max;
458 template <
typename T>
459 ETL_CONSTANT
int statics_char32_t<T>::bits;
461 template <
typename T>
462 ETL_CONSTANT
bool statics_char32_t<T>::is_signed;
465#if ETL_USING_20BIT_TYPES
466 template <
typename T =
void>
467 struct statics___int20
469 typedef __int20 value_type;
471 static ETL_CONSTANT __int20 min = 0x80000;
472 static ETL_CONSTANT __int20 max = 0x7FFFF;
473 static ETL_CONSTANT
int bits = 20;
474 static ETL_CONSTANT
bool is_signed =
true;
477 template <
typename T>
478 ETL_CONSTANT __int20 statics___int20<T>::min;
480 template <
typename T>
481 ETL_CONSTANT __int20 statics___int20<T>::max;
483 template <
typename T>
484 ETL_CONSTANT
int statics___int20<T>::bits;
486 template <
typename T>
487 ETL_CONSTANT
bool statics___int20<T>::is_signed;
489 template <
typename T =
void>
490 struct statics_unsigned___int20
492 typedef unsigned __int20 value_type;
494 static ETL_CONSTANT
unsigned __int20 min = 0;
495 static ETL_CONSTANT
unsigned __int20 max = 0xFFFFF;
496 static ETL_CONSTANT
int bits = 20;
497 static ETL_CONSTANT
bool is_signed =
false;
500 template <
typename T>
501 ETL_CONSTANT
unsigned __int20 statics_unsigned___int20<T>::min;
503 template <
typename T>
504 ETL_CONSTANT
unsigned __int20 statics_unsigned___int20<T>::max;
506 template <
typename T>
507 ETL_CONSTANT
int statics_unsigned___int20<T>::bits;
509 template <
typename T>
510 ETL_CONSTANT
bool statics_unsigned___int20<T>::is_signed;
517 template <
typename T>
543 typedef char value_type;
610#if ETL_USING_20BIT_TYPES
615 struct integral_limits<__int20> :
public private_integral_limits::statics___int20<>
620 struct integral_limits<unsigned __int20> :
public private_integral_limits::statics_unsigned___int20<>
Definition integral_limits.h:518
bitset_ext
Definition absolute.h:40
is_signed
Definition type_traits.h:458
Definition integral_limits.h:129
Definition integral_limits.h:238
Definition integral_limits.h:338
Definition integral_limits.h:288
Definition integral_limits.h:184
Definition integral_limits.h:79
Definition integral_limits.h:104
Definition integral_limits.h:263
Definition integral_limits.h:363
Definition integral_limits.h:313
Definition integral_limits.h:213
Definition integral_limits.h:154