]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix std::reverse_iterator relational operators
authorJonathan Wakely <jwakely@redhat.com>
Sat, 28 Mar 2020 21:52:13 +0000 (21:52 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Sat, 28 Mar 2020 21:52:13 +0000 (21:52 +0000)
commit42cda3ba45fca30e73e1c35d8e19b5ec8af24d98
tree1c6c5cd4868756a8cf29c5fa69256ad95c5d3cb6
parent946a444df340609663975c998edc8dfa47284c38
libstdc++: Fix std::reverse_iterator relational operators

My recent changes to reverse_iterator's comparisons was not the version
of the code (or tests) that I meant to commit, and broke the relational
operators. This fixes them to reverse the order of the comparisons on
the base() iterators.

This also replaces the SFINAE constraints in the return type of the
reverse_iterator and move_iterator comparisons with a requires-clause.
This ensures the constrained overloads are preferred to unconstrained
ones. This means the non-standard same-type overloads can be omitted for
C++20 because they're not needed to solve the problem with std::rel_ops
or the testsuite's greedy_ops::X type.

* include/bits/stl_iterator.h (reverse_iterator): Use requires-clause
to constrain C++20 versions of comparison operators. Fix backwards
logic of relational operators.
(move_iterator): Use requires-clause to constrain comparison operators
in C++20. Do not declare non-standard same-type overloads for C++20.
* testsuite/24_iterators/move_iterator/rel_ops_c++20.cc: Check result
of comparisons and check using greedy_ops type.
* testsuite/24_iterators/reverse_iterator/rel_ops_c++20.cc: Likewise.
* testsuite/24_iterators/move_iterator/greedy_ops.cc: Remove redundant
main function from compile-only test.
* testsuite/24_iterators/reverse_iterator/greedy_ops.cc: Likewise.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/testsuite/24_iterators/move_iterator/greedy_ops.cc
libstdc++-v3/testsuite/24_iterators/move_iterator/rel_ops_c++20.cc
libstdc++-v3/testsuite/24_iterators/reverse_iterator/greedy_ops.cc
libstdc++-v3/testsuite/24_iterators/reverse_iterator/rel_ops_c++20.cc
This page took 0.057597 seconds and 5 git commands to generate.