32 #error THIS HEADER IS A GENERATOR. DO NOT INCLUDE.
53 #ifndef ETL_SMALLEST_INCLUDED
54 #define ETL_SMALLEST_INCLUDED
66 #if ETL_CPP11_SUPPORTED && !defined(ETL_SMALLEST_TYPE_FORCE_CPP03)
73 template <
typename T1,
typename... TRest>
79 using smallest_other =
typename smallest_type<TRest...>::type;
100 template <
typename T1>
101 class smallest_type<T1>
113 #if ETL_CPP14_SUPPORTED
114 template <
typename... T>
115 using smallest_type_t =
typename smallest_type<T...>::type;
118 #if ETL_CPP17_SUPPORTED
119 template <
typename... T>
120 constexpr
size_t smallest_type_v = smallest_type<T...>::size;
131 template <
typename T1,
typename T2 = void,
typename T3 = void,
typename T4 = void,
132 typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
133 typename T9 = void,
typename T10 = void,
typename T11 = void,
typename T12 = void,
134 typename T13 = void,
typename T14 = void,
typename T15 = void,
typename T16 =
void>
140 template <const
bool Boolean,
typename TrueType,
typename FalseType>
145 template <
typename TrueType,
typename FalseType>
146 struct choose_type<true, TrueType, FalseType>
148 typedef TrueType type;
153 template <
typename TrueType,
typename FalseType>
154 struct choose_type<false, TrueType, FalseType>
156 typedef FalseType type;
162 typedef typename smallest_type<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::type smallest_other;
166 typedef typename choose_type<(
sizeof(T1) <
sizeof(smallest_other)),
181 template <
typename T1>
183 void, void, void, void, void, void, void, void>
194 namespace private_smallest
199 template <const
int index>
200 struct best_fit_uint_type;
206 struct best_fit_uint_type<0>
208 typedef uint_least8_t type;
215 struct best_fit_uint_type<1>
217 typedef uint_least16_t type;
224 struct best_fit_uint_type<2>
226 typedef uint_least32_t type;
233 struct best_fit_uint_type<3>
235 typedef uint_least64_t type;
241 template <const
int index>
242 struct best_fit_int_type;
248 struct best_fit_int_type<0>
250 typedef int_least8_t type;
257 struct best_fit_int_type<1>
259 typedef int_least16_t type;
266 struct best_fit_int_type<2>
268 typedef int_least32_t type;
275 struct best_fit_int_type<3>
277 typedef int_least64_t type;
287 template <
size_t NBITS>
288 struct smallest_uint_for_bits
293 static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
294 ((NBITS > 16) ? 1 : 0) +
295 ((NBITS > 32) ? 1 : 0);
299 typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
302 #if ETL_CPP14_SUPPORTED
303 template <
size_t NBITS>
304 using smallest_uint_for_bits_t =
typename smallest_uint_for_bits<NBITS>::type;
313 template <
size_t NBITS>
314 struct smallest_int_for_bits
319 static const int TYPE_INDEX = ((NBITS > 8) ? 1 : 0) +
320 ((NBITS > 16) ? 1 : 0) +
321 ((NBITS > 32) ? 1 : 0);
325 typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
328 #if ETL_CPP14_SUPPORTED
329 template <
size_t NBITS>
330 using smallest_int_for_bits_t =
typename smallest_int_for_bits<NBITS>::type;
339 template <u
intmax_t VALUE>
340 struct smallest_uint_for_value
345 static const int TYPE_INDEX = ((VALUE > UINT_LEAST8_MAX) ? 1 : 0) +
346 ((VALUE > UINT16_MAX) ? 1 : 0) +
347 ((VALUE > UINT32_MAX) ? 1 : 0);
351 typedef typename private_smallest::best_fit_uint_type<TYPE_INDEX>::type type;
354 #if ETL_CPP14_SUPPORTED
355 template <u
intmax_t VALUE>
356 using smallest_uint_for_value_t =
typename smallest_uint_for_value<VALUE>::type;
365 template <const
intmax_t VALUE>
366 struct smallest_int_for_value
371 static const int TYPE_INDEX = (((VALUE > intmax_t(INT_LEAST8_MAX)) || (VALUE < intmax_t(INT_LEAST8_MIN))) ? 1 : 0) +
372 (((VALUE > intmax_t(INT16_MAX)) || (VALUE < intmax_t(INT16_MIN))) ? 1 : 0) +
373 (((VALUE > intmax_t(INT32_MAX)) || (VALUE < intmax_t(INT32_MIN))) ? 1 : 0);
377 typedef typename private_smallest::best_fit_int_type<TYPE_INDEX>::type type;
380 #if ETL_CPP14_SUPPORTED
381 template <
intmax_t VALUE>
382 using smallest_int_for_value_t =
typename smallest_int_for_value<VALUE>::type;
Definition: smallest.h:136
conditional
Definition: type_traits_generator.h:1202
Definition: absolute.h:37
size_of
Definition: type_traits_generator.h:1572