On Thu, Jun 10, 2021 at 11:24:43AM +0100, Jonathan Wakely wrote: > > And I'm not changing the libstdc++ side, where perhaps we could change > > std::is_constant_evaluated definition for > > #ifdef __cpp_if_consteval > > case to if consteval { return true; } else { return false; } > > but we need to keep it defined to __builtin_is_constant_evaluated () > > for C++20 or older. > > Is there any advantage to changing that (cheaper for GCC to evaluate?)
I guess compile-time lost in the noise. > or should we just continue to use the __builtin unconditionally? > > I suppose it's theoretically possible that there could be a non-GCC > compiler where defined(__cpp_if_consteval) is true but > __has_builtin(__builtin_is_constant_evaluated) is false. Up to you. The wording says Equivalent to if consteval { return true; } else { return false; } and return __builtin_is_constant_evaluated (); is equivalent to that. Perhaps some people could appreciate to see it literally there, but we can't use it for C++20 (due to the -Wpedantic warnings or -pedantic-errors errors) and for C++17 and earlier (consteval is not a keyword). Jakub