C++ Logo

std-discussion

Advanced search

Re: How do I know whether a call to a constexpr standard library function is actually a constant expression?

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 15 Nov 2019 14:01:40 -0800
On sexta-feira, 15 de novembro de 2019 13:54:46 PST Brian Bi wrote:
> > If the standard says the function is constexpr, some_args are constant
> > expression too, then it compiles.
>
> If that is actually the rule, it should be written down explicitly in the
> standard.

What other behaviour could there be? What's the point of having a function
marked constexpr if it can't be called from a constexpr context?

If some functions have limitations ,sure, they need to be documented. For
example, I assume that any and all functions with narrow contracts can only be
constexpr-called with arguments that obey those contracts. That is, if
        double sqrt(double)
were to be marked constexpr, a negative parameter would not be constexpr and
becomes IFNDR.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2019-11-15 16:04:01