std::byteswap is a simple C++23 utility from the <bit> header that swaps the order of bytes in an integral variable.
In combination with std::endian (C++20), std::byteswap offers a portable solution when serialized data is stored in a different byte order than the native endianness.
Compiler Explorer link: https://compiler-explorer.com/z/T9Ejxbfna