{
little = /* implementation-defined */,
big = /* implementation-defined */,
native = /* implementation-defined */,
Indicates the endianness of all scalar types:
Corner case platforms are also supported:
sizeof
equal to 1, endianness does not matter and all three values, std::endian::little, std::endian::big, and std::endian::native are the same.enum class endian { #if defined(_MSC_VER) && !defined(__clang__) little = 0, big = 1, native = little #else little = __ORDER_LITTLE_ENDIAN__, big = __ORDER_BIG_ENDIAN__, native = __BYTE_ORDER__ #endif };[edit] Notes [edit] Example
#include <bit> #include <iostream> int main() { if constexpr (std::endian::native == std::endian::big) std::cout << "big-endian\n"; else if constexpr (std::endian::native == std::endian::little) std::cout << "little-endian\n"; else std::cout << "mixed-endian\n"; }
Possible output:
[edit] See alsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4