#pragma once #include #include namespace DB { template constexpr T netToHost(T value) noexcept { if constexpr (std::endian::native != std::endian::big) return std::byteswap(value); return value; } template constexpr T hostToNet(T value) noexcept { if constexpr (std::endian::native != std::endian::big) return std::byteswap(value); return value; } template constexpr T toLittleEndian(T value) noexcept { if constexpr (std::endian::native == std::endian::big) return std::byteswap(value); return value; } template constexpr T toBigEndian(T value) noexcept { if constexpr (std::endian::native != std::endian::big) return std::byteswap(value); return value; } template constexpr T fromLittleEndian(T value) noexcept { if constexpr (std::endian::native == std::endian::big) return std::byteswap(value); return value; } template constexpr T fromBigEndian(T value) noexcept { if constexpr (std::endian::native != std::endian::big) return std::byteswap(value); return value; } }