Parameter
Pack
Compile time mapping of index to type and type to index for a template parameter pack.
For C++11 or above
____________________________________________________________________________________________________
parameter_pack
template <typename... TTypes>
class parameter_pack
Defines
static constexpr size_t size = sizeof...(TTypes);
Template alias
template <size_t Index, typename... TTypes>
using parameter_pack_t
= typename etl::parameter_pack<TTypes...>::template type_from_index_t<Index>;
Type from index and type list.
For C++17 or above
template <typename T, typename... TTypes>
inline constexpr size_t parameter_pack_v
= etl::parameter_pack<TTypes...>::template index_of_type<T>::value;
Index from type and type list.
The class contains two nested templates.
____________________________________________________________________________________________________
index_of_type
template <typename T>
class index_of_type
For C++17 or above
template <typename T>
static constexpr size_t index_of_type_v = index_of_type<T>::value;
____________________________________________________________________________________________________
type_from_index
template <size_t Index>
class type_from_index
template <size_t Index>
using type_from_index_t = typename type_from_index<Index>::type;
____________________________________________________________________________________________________
Examples
using Pack = etl::parameter_pack<char, short, int>;
constexpr size_t size = Pack::size;
size_t indexChar = Pack::index_of_type_v<char>;
size_t indexShort = Pack::index_of_type_v<short>;
size_t indexInt = Pack::index_of_type_v<int>;
size_t indexLong = Pack::index_of_type_v<long>;
using type0 = typename Pack::type_from_index_t<0>;
using type1 = typename Pack::type_from_index_t<1>;
using type2 = typename Pack::type_from_index_t<2>;
using type3 = typename Pack::type_from_index_t<3>;