A common question that comes up from time to time in the world of C++ programming is compile-time determination of endianness. Usually this is done with barely portable #if
There is std::endian in the upcoming C++20.
#include constexpr bool little_endian() noexcept { return std::endian::native == std::endian::little; }