Let's say I have such function declared noexcept
:
int pow(int base, int exp) noexcept
{
return (exp == 0 ? 1 : base * pow(base, exp - 1));
}
From my very little, but slowly growing knowledge of C++, I can noexcept
when I'm certain that function will not throw an exception. I also learned that it can be in some range of values, lets say that I consider my function noexcept
when exp
is smaller than 10, and base
smaller than 8 (just as an example). How can I declare that this function is noexcept
in such a range of values? Or the most I can do is leave a comment for other programmers that it should be within some certain ranges?