What if I make 2 versions of ilog2:
- unchecked_ilog2(T value) - don't checks the input value - ilog2(T value) - returns -1 if value == 0 else returns unchecked_ilog2(value)
Following the line of: http://www.boost.org/doc/libs/1_43_0/libs/math/doc/sf_and_dist/html/math_too...
Maybe, it depends on the relative cost of two: the reason for unchecked_factorial is that low-order factorials are often used inside the inner loop of a computation, where anything more expensive than a simple table lookup is out of the question (and the check can easily be moved outside the loop anyway). Does the same thing apply here.... or is the cost of the check trivial compared to the bit manipulations? I don't know the answers to these BTW, just some questions you might want to think about ;-) ilog2 isn't a bad name BTW, John.