Infinite Recursion in Meta Integer Square Root
Good day, A friend of mine is asking about transforming an integer square root function into a meta-function. Here is the original function: unsigned isqrt(unsigned value) { unsigned sq = 1, dlt = 3; while(sq<=value) { sq += dlt; dlt += 2; } return (dlt>>1) - 1; } I wrote a meta version using constexpr , but he said he can't use the new feature for some reason: constexpr std::size_t isqrt_impl (std::size_t sq, std::size_t dlt, std::size_t value){ return sq <= value ? isqrt_impl(sq+dlt, dlt+2, value) : (dlt >> 1) - 1; } constexpr std::size_t isqrt(std::size_t value){ return isqrt_impl(1, 3,