ipaddress 1.1.0
|
Defines macros to determine byte order. More...
#include "config.hpp"
Go to the source code of this file.
Namespaces | |
namespace | ipaddress |
Namespace dedicated to IP addresses and networks operations. | |
Functions | |
constexpr inline bool | is_little_endian () noexcept |
Checks if the system is little-endian. | |
constexpr inline uint32_t | swap_bytes (uint32_t value) noexcept |
Swaps the bytes of a 32-bit unsigned integer. | |
Defines macros to determine byte order.
This header file contains macros and utility functions to determine and work with the byte order (endianness) of the system. It provides a set of preprocessor directives that establish the byte order based on various conditions, such as user definitions, C++20 standard features, or platform-specific macros.
The file defines IPADDRESS_LITTLE_ENDIAN
and IPADDRESS_BIG_ENDIAN
as constants for comparison and sets IPADDRESS_ENDIAN
accordingly. It also includes functions to check the system's endianness and to swap bytes in an integer, which are useful for network programming and handling data with different endianness.
The determination of endianness is done with a priority order:
std::endian
.IPADDRESS_ENDIAN
.If the endianness cannot be determined, a compilation error is raised prompting the user to define IPADDRESS_ENDIAN
.