v1
Brett 2024-01-02 01:27:43 -05:00
parent 73094dbd6d
commit bf6d15015a
1 changed files with 11 additions and 2 deletions

View File

@ -32,9 +32,9 @@
#define SWAP32(val) bswap_32(val)
#define SWAP64(val) bswap_64(val)
#if __cplusplus >= 202002L
#include <bit>
#define ENDIAN_LOOKUP(little_endian) (std::endian::native == std::endian::little && !little_endian) || \
(std::endian::native == std::endian::big && little_endian)
#else
@ -109,6 +109,15 @@ namespace blt::mem
return prev_size * 2;
return prev_size + default_allocation_block;
}
template<typename R, typename T>
inline static R type_cast(T type)
{
static_assert(sizeof(T) == sizeof(R));
R r;
std::memcpy(&r, &type, sizeof(type));
return r;
}
}
#endif //BLT_MEMORY_UTIL_H