Hi,
The initial intent was log2(0) = -1, you can check if your compiler isn't GCC that count_leading_zeros(T(0)) is always sizeof(T) * 8 (all bits are leading zeros).
But one of the intents of this implementation is performance so, using compiler optimized functions is desired.
So the function to be analyzed in this case is count_leading_zeros.
I can see the ‘need for speed’, but that doesn’t change the argument for using policies to allow users to control at compile time how exceptional situations are handled. Policies should have no effect on run time, apart from any checks implied by the chosen policy.
Paul