Boost logo

Boost :

Subject: Re: [boost] Boost.Exception and constexpr
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2013-01-10 09:22:42


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk