[PATCH 1/3] C++20 constexpr lib part 1/3

Jonathan Wakely jwakely@redhat.com
Thu Aug 1 10:56:00 GMT 2019

On 31/07/19 10:50 -0400, Ed Smith-Rowland via libstdc++ wrote:
>Here is the patch for
>* Implement C++20 p0202 - Add constexpr Modifiers to Functions in 
><algorithm> and <utility> Headers.
>* Implement C++20 p1023 - constexpr comparison operators for std::array.
>Relative to the last effort it is rebased on more recent trunk and I 
>added to <version>.
>There's some chance that I'll have to tweak the macros after the draft 
>comes in but I'd like to get this moving.?? I've got other chunks of 
>constexpr lib coming.?? This passes C++20 testing onx86_64-linux.

Calls to the new __memmove and __memcmp functions need to be qualified
with std:: to prevent ADL. I think we should rename those functions,
but that can happen later.

The new 23_containers/array/comparison_operators/constexpr.cc test
will be UNSUPPORTED by default because it doesn't have the directive
{ dg-options "-std=gnu++2a" }.

The change to the <version> header defines __cpp_lib_constexpr instead
of __cpp_lib_constexpr_algorithms as it should be. For some recent
changes I've added a testcase that does nothing but include <version>
and check the feature test macro, which ensures that it's set
correctly by <version> not just by the other header(s) defining it.
For example, see testsuite/26_numerics/numbers/2.cc added yesterday.

I wonder if the feature test macro should only be defined when
__cpp_lib_is_constant_evaluated is defined, because otherwise some
algos will not be usable constant expressions (e.g. when compiled with
Clang 7.0).

OK for trunk with:

- std:: qualification on the new __mem* functions;
- the dg-options added to the testcase;
- fix the macro in <version> (and ideally add a test for it).


More information about the Libstdc++ mailing list