[committed] libstdc++: Fix constraints on std::optional comparisons [PR 96269]

Jonathan Wakely jwakely@redhat.com
Thu Nov 5 19:50:49 GMT 2020


On 05/11/20 19:09 +0000, Jonathan Wakely wrote:
>The relational operators for std::optional were using the wrong types
>in the declval expressions used to constrain them. Instead of using
>const lvalues they were using non-const rvalues, which meant that a type
>might satisfy the constraints but then give an error when the function
>body was instantiated.
>
>libstdc++-v3/ChangeLog:
>
>	PR libstdc++/96269
>	* include/std/optional (operator==, operator!=, operator<)
>	(operator>, operator<=, operator>=): Fix types used in
>	SFINAE constraints.
>	* testsuite/20_util/optional/relops/96269.cc: New test.
>
>Tested powerpc64le-linux. Committed to trunk.

When concepts are supported we can make the alias templates
__optional_eq_t et al use a requires-expression instead of SFINAE.
This is potentially faster to compile, given expected improvements
to C++20 compilers.

I'm testing this patch.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 2717 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201105/5415c453/attachment.bin>


More information about the Gcc-patches mailing list