#pragma once #include #include "defs.h" using namespace std; template constexpr static T clearLowestBit(T value) { return value & (value - 1); } template constexpr static bool ispow2(T value) { return clearLowestBit(value) == 0; } template constexpr static T ceil2(T value) { T value2 = clearLowestBit(value); if (value2 == 0) return value; while (true) { value = value2; value2 = clearLowestBit(value); if (value2 == 0) return value << 1; } }