Boost logo

Boost Users :

Subject: Re: [Boost-users] generalize boost macros
From: John Maddock (jz.maddock_at_[hidden])
Date: 2019-02-02 19:37:29


On 02/02/2019 19:03, Robert Ramey via Boost-users wrote:
> On 2/1/19 1:08 PM, John Maddock via Boost-users wrote:
>> There has been some work towards making the library constexpr
>> throughout where possible: but I came to the conclusion that it
>> wasn't possible without is_constant_evaluated() from C++20.
>> numeric_limits<float128> might be possible though.
>
>
> Hmm - I've heard that gcc already implements is_constant_evaluated().
> Could be wrong though.  In any case, the capability in the works for
> HAS_IS_CONSTANT_EVALUATED? or similar?  I think I could benefit from
> it right now.

I don't think it's in any released gcc version, but they are busy making
use of it in libstdc++ development I believe, so it's on it's way.  I'm
hoping most compiler vendors will make it available in pre-C++20 mode as
well.  Ah wait, it's scheduled for gcc-9:
https://gcc.gnu.org/projects/cxx-status.html#cxx2a

|__builtin_constant_p almost does what we need, but it's GCC only (clang
supports it, but it doesn't do constexpr detection as it always returns
the same value so far as I can tell).|

|There are some suggested gadgets here:
https://stackoverflow.com/questions/13299394/is-is-constexpr-possible-in-c11
which detect whether a function may be used in a constexpr context, but
nothing that permits you to determine whether the current context is
constexpr or not (one claim to the contrary not withstanding).
|

Best, John.

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net