C++ Logo

STD-DISCUSSION

Advanced search

Subject: 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: 2019-11-15 16:01:40


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

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups