diff --git a/base/math_utils.h b/base/math_utils.h index 9c1bb0c..de00d88 100644 --- a/base/math_utils.h +++ b/base/math_utils.h @@ -34,6 +34,11 @@ namespace base { T div_down(T const &v, T const &divisor) { return v / divisor; } + + template + bool is_power_of_two(T const v) { + return !(v & (v - 1)); + } } //----------------------------------------------------------------