*constexpr* bool isPowerOfTwo()


#1

Hello,

It would be great if isPowerOfTwo() (in juce_MathsFunctions.h) were constexpr -- it's nice to be able to use it in static_assert statements (e.g. to ensure the requested size of a ring buffer backed by an std::array is a power of two). I'm using clang (Xcode), and for me it was just a matter of typing "constexpr" before the bool return type declaration of the function. It requires C++11, however, and I note that you're not using it anywhere else in your code, so maybe it's more trouble than it's worth.

Best regards


#2

Yeah, I'm still avoiding most C++11 features, waiting for the old compilers to go away..

constexpr is something I can add in the same way I did override and noexcept, by emulating it in older compilers, but it hasn't been a big priority for me. Will do it when I can!