]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR libstdc++/90105 make forward_list::sort stable
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Apr 2019 21:47:20 +0000 (21:47 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Apr 2019 21:47:20 +0000 (21:47 +0000)
commita0295ab5313ec37e6f7963c9881a71e8c8a5f513
tree01b9b75eee5f0720c6ef40426a35975e2e2cef91
parent8a3ab00ecd9a113894be5cb8022c9fa1aea36275
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270427 138bc75d-0d04-0410-961f-82ee72b054a4
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]