--- title: "smallest" --- {{< callout type="info">}} Header: `smallest.h` Since: `TBC` {{< /callout >}} Allows the smallest type to be determined. This file is generated from smallest_generator.h. See Generators ## smallest _type Template to determine the smallest type Defines type which is the type of the smallest parameter. Defines size which is the size of the smallest parameter. ### C++ 03 By default, supports up to 16 types. ```cpp template struct smallest_type; ``` ### C++ 11 and above ```cpp template struct smallest_type; ``` ### C++14 and above ```cpp template using smallest_type_t = typename smallest_type::type; ``` ### C++17 and above ```cpp template constexpr size_t smallest_type_v = smallest_type::size; ``` ### Example ```cpp template struct Test { // Defines smallest_t as the smallest type of T1, T2 and T3. typedef typename etl::smallest_type::type largest_t; enum { // Defines size as the size of the largest type. size = etl::largest_type::size; } }; ``` ## smallest_int_for_bits Template to determine the smallest integral type that will accommodate the required number of bits. Defines type which is the type of the smallest integer type. ```cpp template struct smallest_int_for_bits; ``` ### C++14 and above ```cpp template using smallest_int_for_bits_t = typename smallest_int_for_bits::type; ``` ### Example ```cpp // Defines type_t as the type that will accommodate 12 bits. typedef typename etl::smallest_int_for_bits<12>::type type_t; ``` ## smallest_uint_for_bits Template to determine the smallest integral type that will accommodate the required number of bits. Defines type which is the type of the smallest unsigned integer type. ```cpp template struct smallest_uint_for_bits; ``` ### C++14 and above ```cpp template using smallest_uint_for_bits_t = typename smallest_uint_for_bits::type; ``` ### Example ```cpp // Defines type_t as the type that will accommodate 12 bits. typedef typename etl::smallest_uint_for_bits<>::type type_t; ``` ## smallest_int_for_value Template to determine the smallest integral type that will accommodate the value. Defines type which is the type of the smallest integer type. ```cpp template struct smallest_int_for_value; ``` ### C++14 and above ```cpp template using smallest_int_for_value_t = typename smallest_int_for_value::type; ``` ### Example ```cpp // Defines type_t as the signed type that will accommodate a value of 193. typedef typename etl::smallest_int_for_value<193>::type type_t; ``` ## smallest_uint_for_value Template to determine the smallest unsigned integral type that will accommodate the value. Defines type which is the type of the smallest unsigned integer type. ```cpp template struct smallest_uint_for_value; ``` ### C++14 and above ```cpp template using smallest_uint_for_value_t = typename smallest_uint_for_value::type; ``` ### Example ```cpp // Defines type_t as the smallest unsigned type that will accommodate a value of 193. typedef typename etl::smallest_uint_for_value<193>::type type_t; ```