Passing constexpr objects around
Solution 1:
The reason is that inside a constexpr
function, parameters aren't constant expressions, regardless of whether the arguments are. You can call constexpr
functions inside others, but the parameters of a constexpr
function aren't constexpr
inside, making any function call (even to constexpr
functions) not a constant expression - inside.
const auto nOpen = numOpen( str );
Suffices. Only once you view the call from outside the constexpr
-ness of the expressions inside is verified, deciding whether the whole call is constexpr
or not.