
10 Jan
2013
10 Jan
'13
2:22 p.m.
On 10.01.2013 14:49, Andrey Semashev wrote:
I must be missing something crucial. My understanding was that constexpr functions should be evaluated at compile time, am I wrong? Yes. A constexpr function *can* be evaluated at compile time if all its arguments are constant expressions and evaluation using those arguments doesn't hit anything that isn't allowed (like a throw). If that is the case, the result itself may be used as a constant expression. Otherwise, it's a normal function call. A constexpr function only *must* be evaluated at compile time if the result has to be a constant expression. In that case, it is a compile time error if it cannot be evaluated.
Sebastian