Skip to content
Snippets Groups Projects
Commit b838e58d authored by bunnei's avatar bunnei
Browse files

common: alignment: Add a helper function for generic alignment checking.

parent ad48ebb2
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,13 @@ constexpr bool IsWordAligned(T value) {
return (value & 0b11) == 0;
}
template <typename T>
constexpr bool IsAligned(T value, std::size_t alignment) {
using U = typename std::make_unsigned<T>::type;
const U mask = static_cast<U>(alignment - 1);
return (value & mask) == 0;
}
template <typename T, std::size_t Align = 16>
class AlignmentAllocator {
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment