Skip to content

endian

Header: endian.h
Since: TBC

Constants & utilities for endianess.

For endian specific integral types, see unaligned_type.

The values for endianness are dependant on the platform setup.

If ETL_ENDIAN_NATIVE is defined by the user, then
etl::endian::little = 0
etl::endian::big = 1

If ETL_ENDIAN_NATIVE is not defined by the user, then the ETL selects an appropriate definition.
 If ETL_CPP20_SUPPORTED == 1 and ETL_USING_STL == 1 then
  etl::endian::little = std::endian::little
  etl::endian::big = std::endian::big
  etl::endian::native = std::endian::native

else if __BYTE_ORDER__ is defined then
 If __ORDER_LITTLE_ENDIAN__ is defined then
  etl::endian::little = __ORDER_LITTLE_ENDIAN__
  etl::endian::big = __ORDER_BIG_ENDIAN__
  etl::endian::native = __BYTE_ORDER__

 else if __LITTLE_ENDIAN__ is defined
  etl::endian::little = __LITTLE_ENDIAN__
  etl::endian::big = __BIG_ENDIAN__
  etl::endian::native = __BYTE_ORDER__

else
The user needs to define ETL_ENDIAN_NATIVE either as 0 for little endian or 1 for big endian.

endian

A smart enumeration defining little and big members.

etl::endian::little;
etl::endian::big;

endianness

Interrogates the endianness of the platform.

etl::endian operator ()() const

constexpr if ETL_CPP11_SUPPORTED == 1 and ETL_ENDIAN_NATIVE is defined.


operator etl::endian() const

constexpr if ETL_CPP11_SUPPORTED == 1 and ETL_ENDIAN_NATIVE is defined.


static etl::endian value()

constexpr if ETL_CPP11_SUPPORTED == 1 and ETL_ENDIAN_NATIVE is defined.

Host to network

template <typename T>
T hton(T value)

Description
Converts value from host to network ordering.

Network to host

template <typename T>
T ntoh(T value)

Description
Converts value from network to host ordering.