libstdc++: Fix __normal_iterator comparisons for C++20
authorJonathan Wakely <jwakely@redhat.com>
Tue, 21 Apr 2020 22:43:27 +0000 (23:43 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 21 Apr 2020 22:46:54 +0000 (23:46 +0100)
commit87841658d4fa5174d1797ee0abc73b3b3f11cad4
tree6521b688b2dcde6cafaebba2957f917bb10c959c
parent0e665f256b4ac8c5f78713ebd4e9378fd4ecf5a8
libstdc++: Fix __normal_iterator comparisons for C++20

This fixes a regression introduced when I replaced __normal_iterator's
relational operators with operator<=>. If the wrapped iterator type
doesn't define operator<=> then __normal_iterator doesdn't either, which
breaks any use of fancy pointers that don't define <=>. The regression
was found when trying to build cmcstl2.

The solution is to use synth-three-way to define __normal_iterator's
spaceship operator, so that it is still defined even if the wrapped type
only supports operator<.

* include/bits/stl_iterator.h (__normal_iterator): Use synth-three-way
to define operator<=>.
* testsuite/24_iterators/normal_iterator/cmp_c++20.cc: New test.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/testsuite/24_iterators/normal_iterator/cmp_c++20.cc [new file with mode: 0644]