]> git.ipfire.org Git - thirdparty/gcc.git/commit - libstdc++-v3/include/bits/forward_list.tcc
PR libstdc++/90105 make forward_list::sort stable
authorJonathan Wakely <jwakely@redhat.com>
Wed, 17 Apr 2019 21:47:20 +0000 (22:47 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 17 Apr 2019 21:47:20 +0000 (22:47 +0100)
commit8c7100650ef446af8a46ac14042d6ae4a8abd5a6
tree01b9b75eee5f0720c6ef40426a35975e2e2cef91
parent2ad37a09fa0c457c48dfa83079a9e078e03d5770
PR libstdc++/90105 make forward_list::sort stable

While testing the fix I also discovered that operator== assumes the
elements are comparable with operator!= which is not required.

PR libstdc++/90105
* include/bits/forward_list.h (operator==): Do not use operator!= to
compare elements.
(forward_list<T, A>::sort(Comp)): When elements are equal take the one
earlier in the list, so that sort is stable.
* testsuite/23_containers/forward_list/operations/90105.cc: New test.
* testsuite/23_containers/forward_list/comparable.cc: Test with
types that meet the minimum EqualityComparable and LessThanComparable
requirements. Remove irrelevant comment.

From-SVN: r270427
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/forward_list.tcc
libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc
libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc [new file with mode: 0644]