Skip to content

Instantly share code, notes, and snippets.

View z-ninja's full-sized avatar

zninja z-ninja

View GitHub Profile
@z-ninja
z-ninja / Endian-c++17.hpp
Created November 24, 2021 22:18
Endian conversion, byte swap for big and little endian.
#include <cstdint>
#include <type_traits>
#if __cplusplus > 201703L
#include <bit>
namespace Endian {
template <typename T>
struct alignas(alignof(T)) type_bytes {
unsigned char u8[sizeof(T)];
};