Function is_power_of_2
Synopsis
#include "breeze/mathematics/is_power_of_2.hpp"
template <typename T>
constexpr bool is_power_of_2(T x) noexcept
Description
- Returns
true
if an only ifx
is a power of two.- Note
- C++20 has
std::has_single_bit()
, which can replace this one (but only works with unsigned types and, on most implementations, qualified versions thereof).
Source
Line 32 in breeze/mathematics/is_power_of_2.hpp.