A C++ template library for embedded applications
Designed and maintained by
Aster Consulting Ltd

largest

Allows the largest type or largest alignment to be determined.

largest_type

Template to determine the largest type and size. Supports up to 16 types.
Defines type which is the type of the largest parameter.
Defines size which is the size of the largest parameter.

template <typename T1,         typename T2  = void, typename T3  = void, typename T4  = void,
          typename T5  = void, typename T6  = void, typename T7  = void, typename T8  = void,
          typename T9  = void, typename T10 = void, typename T11 = void, typename T12 = void,
          typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest_type;

Example

template <typename T1, typename T2, typename T3>
struct Test
{
  // Defines largest_t as the largest type of T1, T2 and T3.
  typedef typename etl::largest_type<T1, T2, T3>::type largest_t;

  enum
  {
    // Defines size as the size of the largest type.
    size = etl::largest_type<T1, T2, T3>::size;
  }
};

largest_alignment

Template to determine the largest alignment. Supports up to 16 types.
Defines value which is the largest alignment.

template <typename T1,         typename T2  = void, typename T3  = void, typename T4  = void,
          typename T5  = void, typename T6  = void, typename T7  = void, typename T8  = void,
          typename T9  = void, typename T10 = void, typename T11 = void, typename T12 = void,
          typename T13 = void, typename T14 = void, typename T15 = void, typename T16 = void>
struct largest_alignment;

Example

template <typename T1, typename T2, typename T3>
struct Test
{
  // Defines ALIGNMENT with the value of the largest alignment of T1, T2 and T3.
  enum
  {
    ALIGNMENT = etl::largest_alignment<T1, T2, T3>::value
  };
};
largest.h