std::endian
| Defined in header <bit>
|
||
| enum class endian { |
(since C++20) | |
Indicates the endianness of all scalar types:
- If all scalar types are little-endian,
std::endian::nativeequalsstd::endian::little - If all scalar types are big-endian,
std::endian::nativeequalsstd::endian::big
Corner case platforms are also supported:
- If all scalar types have sizeof equal to 1, endianness does not matter and all three values,
std::endian::little,std::endian::big, andstd::endian::nativeare the same. - If the platform uses mixed endian,
std::endian::nativeequals neitherstd::endian::bignorstd::endian::little.
[edit] Possible implementation
enum class endian { #ifdef _WIN32 little = 0, big = 1, native = little #else little = __ORDER_LITTLE_ENDIAN__, big = __ORDER_BIG_ENDIAN__, native = __BYTE_ORDER__ #endif };
[edit] Example
Possible output:
little-endian
[edit] See also
| (C++23) |
reverses the bytes in the given integer value (function template) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
