How to check if a pointer points to a properly aligned memory location?
If the remainder isn’t zero when dividing the address with the desired alignment, then the address isn’t aligned. inline bool is_aligned(const void * ptr, std::uintptr_t alignment) noexcept { auto iptr = reinterpret_cast<std::uintptr_t>(ptr); return !(iptr % alignment); } Ths can’t be constexpr though, because of the cast. Also, this relies on the implementation-defined fact that the … Read more