31constexpr Type
alignUp(Type arg, size_t alignment)
33 if constexpr (std::is_pointer_v<Type>) {
34 return Type(alignUp(std::intptr_t(arg), alignment));
36 Q_ASSERT(isPowerOfTwo(alignment));
37 return Type((arg + (Type(alignment) - 1)) & ~Type(alignment - 1));
44 if constexpr (std::is_pointer_v<Type>) {
45 return Type(alignDown(std::intptr_t(arg), alignment));
47 Q_ASSERT(isPowerOfTwo(alignment));
48 return arg & ~Type(alignment - 1);
53constexpr bool isAligned(IntType arg, size_t alignment)
55 if constexpr (std::is_pointer_v<IntType>) {
56 return isAligned(std::intptr_t(arg), alignment);
58 Q_ASSERT(isPowerOfTwo(alignment));
59 return (arg & (IntType(alignment) - 1)) == 0;