11
A constexpr function must just consist of a return statement and every argument should be known at compile time:
// constexpr functions use recursion rather than iteration
constexpr int factorial(int n)
{
return n <= 1 ? 1 : (n * factorial(n-1));
}
Why just the return statement? I mean, why this is wrong?
// constexpr functions use recursion rather than iteration
constexpr int factorial(int n)
{
int a = 222; //another variable
return n <= 1 ? 1 : (n * factorial(n-1));
}