Functions for memory alignment.
Functions | |
bool | pw::IsAlignedAs (const void *ptr, size_t alignment) |
Returns whether the given pointer meets the given alignment requirement. | |
template<typename T > | |
bool | pw::IsAlignedAs (const void *ptr) |
constexpr size_t | pw::AlignDown (uintptr_t value, size_t alignment) |
Returns the value rounded down to the nearest multiple of alignment. | |
template<typename T > | |
constexpr T * | pw::AlignDown (T *value, size_t alignment) |
Returns the value rounded down to the nearest multiple of alignment. | |
constexpr size_t | pw::AlignUp (uintptr_t value, size_t alignment) |
Returns the value rounded up to the nearest multiple of alignment. | |
template<typename T > | |
constexpr T * | pw::AlignUp (T *value, size_t alignment) |
Returns the value rounded up to the nearest multiple of alignment. | |
constexpr size_t | pw::Padding (size_t length, size_t alignment) |
Returns the number of padding bytes required to align the provided length. | |
ByteSpan | pw::GetAlignedSubspan (ByteSpan bytes, size_t alignment) |
Returns the largest aligned subspan of a given byte span.
The subspan will start and end on alignment boundaries.
ByteSpan
within bytes
aligned to alignment
, or an empty ByteSpan
if alignment was not possible. bool pw::IsAlignedAs | ( | const void * | ptr | ) |
Returns whether the given pointer meets the alignment requirement for the given type.