A C++ template library for embedded applications
MIT licensed
Join the ETL community
Designed and
maintained by
John Wellbelove
Like the ETL? Become a patron!

Type Select

Compile time mapping of id to type. When etl::type_lookup is OTT.
Type ids must be sequential from zero.

This file is generated from type_select_generator.h and can be created by running generate_type_select.bat.



Creates a class for compile time id to type.
etl::type_select<typename T1, ...>

The number of types that can be handled is determined by the generator.

The class contains a nested template.


Gets the type from the id.
select<const size_t ID>

type The associated type.



  INT32  = 0,
  STRING = 1,
  UINT8  = 2,
  OTHER  = 3

// Type from Id.
typedef etl::type_select<int32_t, std::string, uint8_t> Types;

// int32_t
typename Types::select<INT32>::type

// uint8_t
typename Types::select<UINT8>::type

// std::string
typename Types::select<STRING>::type

// Compile error
typename Types::select<OTHER>::type