42 return std::endian::native == std::endian::little;
50 return std::endian::native == std::endian::big;
59 static_assert(std::is_arithmetic<T>::value,
"swab() requires an arithmetic type");
60 constexpr size_t size =
sizeof(
T);
61 if constexpr (size == 1)
return;
62 unsigned char *data =
reinterpret_cast<unsigned char*
>(&
value);
64 for (
size_t i = 0;
i < size / 2; ++
i) {
65 std::swap(data[
i], data[size -
i - 1]);
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Provides system-level utility functions.
Definition system.h:29
static constexpr bool isBigEndian()
Returns true if the host byte order is big-endian.
Definition system.h:49
static void swapEndian(T &value)
Reverses the byte order of an arithmetic value in place.
Definition system.h:58
static String hostname()
Returns the hostname of the machine.
static void makeNativeEndian(T &value)
Converts a value to native endian if its byte order differs.
Definition system.h:76
static String demangleSymbol(const char *symbol, bool useCache=true)
Demangles a C++ symbol name into a human-readable form.
static constexpr bool isLittleEndian()
Returns true if the host byte order is little-endian.
Definition system.h:41
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
const T & value(const Result< T > &r)
Returns the value from a Result.
Definition result.h:56