31#ifndef ETL_INTEGRAL_LIMITS_INCLUDED
32#define ETL_INTEGRAL_LIMITS_INCLUDED
49 #define LLONG_MAX 9223372036854775807LL
53 #define LLONG_MIN (-LLONG_MAX - 1LL)
57 #define ULLONG_MAX 18446744073709551615ULL
62 namespace private_integral_limits
76 template <
typename T =
void>
79 typedef signed char value_type;
81 static ETL_CONSTANT
signed char min = SCHAR_MIN;
82 static ETL_CONSTANT
signed char max = SCHAR_MAX;
83 static ETL_CONSTANT
int bits = CHAR_BIT;
84 static ETL_CONSTANT
bool is_signed = etl::is_signed<signed char>::value;
88 ETL_CONSTANT
signed char statics_signed_char<T>::min;
91 ETL_CONSTANT
signed char statics_signed_char<T>::max;
94 ETL_CONSTANT
int statics_signed_char<T>::bits;
97 ETL_CONSTANT
bool statics_signed_char<T>::is_signed;
101 template <
typename T =
void>
104 typedef unsigned char value_type;
106 static ETL_CONSTANT
unsigned char min = 0;
107 static ETL_CONSTANT
unsigned char max = UCHAR_MAX;
108 static ETL_CONSTANT
int bits = CHAR_BIT;
109 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned char>::value;
112 template <
typename T>
113 ETL_CONSTANT
unsigned char statics_unsigned_char<T>::min;
115 template <
typename T>
116 ETL_CONSTANT
unsigned char statics_unsigned_char<T>::max;
118 template <
typename T>
119 ETL_CONSTANT
int statics_unsigned_char<T>::bits;
121 template <
typename T>
122 ETL_CONSTANT
bool statics_unsigned_char<T>::is_signed;
126 template <
typename T =
void>
129 typedef char value_type;
131 static ETL_CONSTANT
char min = (etl::is_signed<char>::value) ? SCHAR_MIN : 0;
132 static ETL_CONSTANT
char max = (etl::is_signed<char>::value) ? SCHAR_MAX :
static_cast<char>(UCHAR_MAX);
133 static ETL_CONSTANT
int bits = CHAR_BIT;
134 static ETL_CONSTANT
bool is_signed = etl::is_signed<char>::value;
137 template <
typename T>
138 ETL_CONSTANT
char statics_char<T>::min;
140 template <
typename T>
141 ETL_CONSTANT
char statics_char<T>::max;
143 template <
typename T>
144 ETL_CONSTANT
int statics_char<T>::bits;
146 template <
typename T>
147 ETL_CONSTANT
bool statics_char<T>::is_signed;
151 template <
typename T =
void>
154 typedef wchar_t value_type;
156 static ETL_CONSTANT
wchar_t min = WCHAR_MIN;
157 static ETL_CONSTANT
wchar_t max = WCHAR_MAX;
158 static ETL_CONSTANT
int bits = CHAR_BIT *
sizeof(wchar_t);
159 static ETL_CONSTANT
bool is_signed = etl::is_signed<wchar_t>::value;
162 template <
typename T>
163 ETL_CONSTANT
wchar_t statics_wchar_t<T>::min;
165 template <
typename T>
166 ETL_CONSTANT
wchar_t statics_wchar_t<T>::max;
168 template <
typename T>
169 ETL_CONSTANT
int statics_wchar_t<T>::bits;
171 template <
typename T>
172 ETL_CONSTANT
bool statics_wchar_t<T>::is_signed;
176#if defined(ETL_COMPILER_MICROSOFT)
177 #pragma warning(push)
178 #pragma warning(disable : 4309)
181 template <
typename T =
void>
184 typedef short value_type;
186 static ETL_CONSTANT
short min = SHRT_MIN;
187 static ETL_CONSTANT
short max = SHRT_MAX;
188 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(short) /
sizeof(char));
189 static ETL_CONSTANT
bool is_signed = etl::is_signed<short>::value;
192 template <
typename T>
193 ETL_CONSTANT
short statics_short<T>::min;
195 template <
typename T>
196 ETL_CONSTANT
short statics_short<T>::max;
198 template <
typename T>
199 ETL_CONSTANT
int statics_short<T>::bits;
201 template <
typename T>
202 ETL_CONSTANT
bool statics_short<T>::is_signed;
204#if defined(ETL_COMPILER_MICROSOFT)
210 template <
typename T =
void>
213 typedef unsigned short value_type;
215 static ETL_CONSTANT
unsigned short min = 0;
216 static ETL_CONSTANT
unsigned short max = USHRT_MAX;
217 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned short) /
sizeof(char));
218 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned short>::value;
221 template <
typename T>
222 ETL_CONSTANT
unsigned short statics_unsigned_short<T>::min;
224 template <
typename T>
225 ETL_CONSTANT
unsigned short statics_unsigned_short<T>::max;
227 template <
typename T>
228 ETL_CONSTANT
int statics_unsigned_short<T>::bits;
230 template <
typename T>
231 ETL_CONSTANT
bool statics_unsigned_short<T>::is_signed;
235 template <
typename T =
void>
238 typedef int value_type;
240 static ETL_CONSTANT
int min = INT_MIN;
241 static ETL_CONSTANT
int max = INT_MAX;
242 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(int) /
sizeof(char));
243 static ETL_CONSTANT
bool is_signed = etl::is_signed<int>::value;
246 template <
typename T>
247 ETL_CONSTANT
int statics_int<T>::min;
249 template <
typename T>
250 ETL_CONSTANT
int statics_int<T>::max;
252 template <
typename T>
253 ETL_CONSTANT
int statics_int<T>::bits;
255 template <
typename T>
256 ETL_CONSTANT
bool statics_int<T>::is_signed;
260 template <
typename T =
void>
263 typedef unsigned int value_type;
265 static ETL_CONSTANT
unsigned int min = 0;
266 static ETL_CONSTANT
unsigned int max = UINT_MAX;
267 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned int) /
sizeof(char));
268 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned int>::value;
271 template <
typename T>
272 ETL_CONSTANT
unsigned int statics_unsigned_int<T>::min;
274 template <
typename T>
275 ETL_CONSTANT
unsigned int statics_unsigned_int<T>::max;
277 template <
typename T>
278 ETL_CONSTANT
int statics_unsigned_int<T>::bits;
280 template <
typename T>
281 ETL_CONSTANT
bool statics_unsigned_int<T>::is_signed;
285 template <
typename T =
void>
288 typedef long value_type;
290 static ETL_CONSTANT
long min = LONG_MIN;
291 static ETL_CONSTANT
long max = LONG_MAX;
292 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(long) /
sizeof(char));
293 static ETL_CONSTANT
bool is_signed = etl::is_signed<long>::value;
296 template <
typename T>
297 ETL_CONSTANT
long statics_long<T>::min;
299 template <
typename T>
300 ETL_CONSTANT
long statics_long<T>::max;
302 template <
typename T>
303 ETL_CONSTANT
int statics_long<T>::bits;
305 template <
typename T>
306 ETL_CONSTANT
bool statics_long<T>::is_signed;
310 template <
typename T =
void>
313 typedef unsigned long value_type;
315 static ETL_CONSTANT
unsigned long min = 0;
316 static ETL_CONSTANT
unsigned long max = ULONG_MAX;
317 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned long) /
sizeof(char));
318 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned long>::value;
321 template <
typename T>
322 ETL_CONSTANT
unsigned long statics_unsigned_long<T>::min;
324 template <
typename T>
325 ETL_CONSTANT
unsigned long statics_unsigned_long<T>::max;
327 template <
typename T>
328 ETL_CONSTANT
int statics_unsigned_long<T>::bits;
330 template <
typename T>
331 ETL_CONSTANT
bool statics_unsigned_long<T>::is_signed;
335 template <
typename T =
void>
338 typedef long long value_type;
340 static ETL_CONSTANT
long long min = LLONG_MIN;
341 static ETL_CONSTANT
long long max = LLONG_MAX;
342 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
long long) /
sizeof(char));
343 static ETL_CONSTANT
bool is_signed = etl::is_signed<long long>::value;
346 template <
typename T>
347 ETL_CONSTANT
long long statics_long_long<T>::min;
349 template <
typename T>
350 ETL_CONSTANT
long long statics_long_long<T>::max;
352 template <
typename T>
353 ETL_CONSTANT
int statics_long_long<T>::bits;
355 template <
typename T>
356 ETL_CONSTANT
bool statics_long_long<T>::is_signed;
360 template <
typename T =
void>
363 typedef unsigned long value_type;
365 static ETL_CONSTANT
unsigned long long min = 0;
366 static ETL_CONSTANT
unsigned long long max = ULLONG_MAX;
367 static ETL_CONSTANT
int bits = CHAR_BIT * (
sizeof(
unsigned long long) /
sizeof(char));
368 static ETL_CONSTANT
bool is_signed = etl::is_signed<unsigned long long>::value;
371 template <
typename T>
372 ETL_CONSTANT
unsigned long long statics_unsigned_long_long<T>::min;
374 template <
typename T>
375 ETL_CONSTANT
unsigned long long statics_unsigned_long_long<T>::max;
377 template <
typename T>
378 ETL_CONSTANT
int statics_unsigned_long_long<T>::bits;
380 template <
typename T>
381 ETL_CONSTANT
bool statics_unsigned_long_long<T>::is_signed;
383#if ETL_HAS_NATIVE_CHAR8_T
386 template <
typename T =
void>
387 struct statics_char8_t
391 static ETL_CONSTANT
char8_t min =
static_cast<char8_t>((etl::is_signed<char8_t>::value) ? SCHAR_MIN : 0);
392 static ETL_CONSTANT
char8_t max = (etl::is_signed<char8_t>::value) ?
static_cast<char8_t>(SCHAR_MAX) :
static_cast<char8_t>(UCHAR_MAX);
393 static ETL_CONSTANT
int bits = CHAR_BIT;
394 static ETL_CONSTANT
bool is_signed = etl::is_signed<char8_t>::value;
397 template <
typename T>
398 ETL_CONSTANT
char8_t statics_char8_t<T>::min;
400 template <
typename T>
401 ETL_CONSTANT
char8_t statics_char8_t<T>::max;
403 template <
typename T>
404 ETL_CONSTANT
int statics_char8_t<T>::bits;
406 template <
typename T>
407 ETL_CONSTANT
bool statics_char8_t<T>::is_signed;
410#if ETL_HAS_NATIVE_CHAR16_T
413 template <
typename T =
void>
414 struct statics_char16_t
418 static ETL_CONSTANT
char16_t min = 0;
419 static ETL_CONSTANT
char16_t max = 0xFFFFU;
420 static ETL_CONSTANT
int bits = 16;
421 static ETL_CONSTANT
bool is_signed =
false;
424 template <
typename T>
425 ETL_CONSTANT
char16_t statics_char16_t<T>::min;
427 template <
typename T>
428 ETL_CONSTANT
char16_t statics_char16_t<T>::max;
430 template <
typename T>
431 ETL_CONSTANT
int statics_char16_t<T>::bits;
433 template <
typename T>
434 ETL_CONSTANT
bool statics_char16_t<T>::is_signed;
437#if ETL_HAS_NATIVE_CHAR32_T
440 template <
typename T =
void>
441 struct statics_char32_t
443 typedef char32_t value_type;
445 static ETL_CONSTANT
char32_t min = 0;
446 static ETL_CONSTANT
char32_t max = 0xFFFFFFFFU;
447 static ETL_CONSTANT
int bits = 32;
448 static ETL_CONSTANT
bool is_signed =
false;
451 template <
typename T>
452 ETL_CONSTANT
char32_t statics_char32_t<T>::min;
454 template <
typename T>
455 ETL_CONSTANT
char32_t statics_char32_t<T>::max;
457 template <
typename T>
458 ETL_CONSTANT
int statics_char32_t<T>::bits;
460 template <
typename T>
461 ETL_CONSTANT
bool statics_char32_t<T>::is_signed;
464#if ETL_USING_20BIT_TYPES
465 template <
typename T =
void>
466 struct statics___int20
468 typedef __int20 value_type;
470 static ETL_CONSTANT __int20 min = 0x80000;
471 static ETL_CONSTANT __int20 max = 0x7FFFF;
472 static ETL_CONSTANT
int bits = 20;
473 static ETL_CONSTANT
bool is_signed =
true;
476 template <
typename T>
477 ETL_CONSTANT __int20 statics___int20<T>::min;
479 template <
typename T>
480 ETL_CONSTANT __int20 statics___int20<T>::max;
482 template <
typename T>
483 ETL_CONSTANT
int statics___int20<T>::bits;
485 template <
typename T>
486 ETL_CONSTANT
bool statics___int20<T>::is_signed;
488 template <
typename T =
void>
489 struct statics_unsigned___int20
491 typedef unsigned __int20 value_type;
493 static ETL_CONSTANT
unsigned __int20 min = 0;
494 static ETL_CONSTANT
unsigned __int20 max = 0xFFFFF;
495 static ETL_CONSTANT
int bits = 20;
496 static ETL_CONSTANT
bool is_signed =
false;
499 template <
typename T>
500 ETL_CONSTANT
unsigned __int20 statics_unsigned___int20<T>::min;
502 template <
typename T>
503 ETL_CONSTANT
unsigned __int20 statics_unsigned___int20<T>::max;
505 template <
typename T>
506 ETL_CONSTANT
int statics_unsigned___int20<T>::bits;
508 template <
typename T>
509 ETL_CONSTANT
bool statics_unsigned___int20<T>::is_signed;
516 template <
typename T>
542 typedef char value_type;
609#if ETL_USING_20BIT_TYPES
614 struct integral_limits<__int20> :
public private_integral_limits::statics___int20<>
619 struct integral_limits<unsigned __int20> :
public private_integral_limits::statics_unsigned___int20<>
Definition integral_limits.h:517
is_signed
Definition type_traits.h:458
Definition integral_limits.h:128
Definition integral_limits.h:237
Definition integral_limits.h:337
Definition integral_limits.h:287
Definition integral_limits.h:183
Definition integral_limits.h:78
Definition integral_limits.h:103
Definition integral_limits.h:262
Definition integral_limits.h:362
Definition integral_limits.h:312
Definition integral_limits.h:212
Definition integral_limits.h:153