#pragma once namespace Common { template bool IsAligned(T value, unsigned int alignment) { return (value % static_cast(alignment)) == 0; } template T AlignUp(T value, unsigned int alignment) { return (value + static_cast(alignment - 1)) / static_cast(alignment) * static_cast(alignment); } template T AlignDown(T value, unsigned int alignment) { return value / static_cast(alignment) * static_cast(alignment); } template bool IsAlignedPow2(T value, unsigned int alignment) { return (value & static_cast(alignment - 1)) == 0; } template T AlignUpPow2(T value, unsigned int alignment) { return (value + static_cast(alignment - 1)) & static_cast(~static_cast(alignment - 1)); } template T AlignDownPow2(T value, unsigned int alignment) { return value & static_cast(~static_cast(alignment - 1)); } template bool IsPow2(T value) { return (value & (value - 1)) == 0; } } // namespace Common