From e0b9bc230ac50c67c63f303b70e72b34a7c516fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dumont?= Date: Fri, 5 Oct 2018 16:01:39 +0000 Subject: [PATCH] =?UTF-8?q?2018-10-05=20=20Fran=C3=A7ois=20Dumont=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * include/bits/stl_tree.h (_Rb_tree_iterator<>::operator==): Make inline friend. (_Rb_tree_iterator<>::operator!=): Likewise. (_Rb_tree_const_iterator<>::operator==): Likewise. (_Rb_tree_const_iterator<>::operator!=): Likewise. (operator==(const _Rb_tree_iterator<>&, const _Rb_tree_const_iterator&)): Remove. (operator!=(const _Rb_tree_iterator<>&, const _Rb_tree_const_iterator&)): Remove. (operator==(const _Rb_tree<>&, const _Rb_tree<>&)): Make inline friend. (operator<(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. (operator!=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise and deprecate. (operator>(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. (operator<=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. (operator>=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. * include/debug/map.h (map<>::erase(const_iterator, const_iterator)): Compare __victim with _Base::cend(). * include/debug/multimap.h (multimap<>::erase(const_iterator, const_iterator)): Likewise. * include/debug/set.h (set<>::erase(const_iterator, const_iterator)): Compare __victim with _Base::cend(). * include/debug/multiset.h (multiset<>::erase(const_iterator, const_iterator)): Likewise. From-SVN: r264875 --- libstdc++-v3/ChangeLog | 27 ++++++ libstdc++-v3/include/bits/stl_tree.h | 122 ++++++++++---------------- libstdc++-v3/include/debug/map.h | 2 +- libstdc++-v3/include/debug/multimap.h | 2 +- libstdc++-v3/include/debug/multiset.h | 2 +- libstdc++-v3/include/debug/set.h | 2 +- 6 files changed, 77 insertions(+), 80 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 84e61ca955c..06718b5520d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,30 @@ +2018-10-05 François Dumont + + * include/bits/stl_tree.h + (_Rb_tree_iterator<>::operator==): Make inline friend. + (_Rb_tree_iterator<>::operator!=): Likewise. + (_Rb_tree_const_iterator<>::operator==): Likewise. + (_Rb_tree_const_iterator<>::operator!=): Likewise. + (operator==(const _Rb_tree_iterator<>&, + const _Rb_tree_const_iterator&)): Remove. + (operator!=(const _Rb_tree_iterator<>&, + const _Rb_tree_const_iterator&)): Remove. + (operator==(const _Rb_tree<>&, const _Rb_tree<>&)): Make inline friend. + (operator<(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. + (operator!=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise and + deprecate. + (operator>(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. + (operator<=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. + (operator>=(const _Rb_tree<>&, const _Rb_tree<>&)): Likewise. + * include/debug/map.h (map<>::erase(const_iterator, const_iterator)): + Compare __victim with _Base::cend(). + * include/debug/multimap.h + (multimap<>::erase(const_iterator, const_iterator)): Likewise. + * include/debug/set.h (set<>::erase(const_iterator, const_iterator)): + Compare __victim with _Base::cend(). + * include/debug/multiset.h + (multiset<>::erase(const_iterator, const_iterator)): Likewise. + 2018-10-03 Jonathan Wakely PR libstdc++/59439 diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 70d7483c7b1..87e57108deb 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -260,11 +260,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef _Tp* pointer; typedef bidirectional_iterator_tag iterator_category; - typedef ptrdiff_t difference_type; + typedef ptrdiff_t difference_type; - typedef _Rb_tree_iterator<_Tp> _Self; - typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; - typedef _Rb_tree_node<_Tp>* _Link_type; + typedef _Rb_tree_iterator<_Tp> _Self; + typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; + typedef _Rb_tree_node<_Tp>* _Link_type; _Rb_tree_iterator() _GLIBCXX_NOEXCEPT : _M_node() { } @@ -311,13 +311,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __tmp; } - bool - operator==(const _Self& __x) const _GLIBCXX_NOEXCEPT - { return _M_node == __x._M_node; } + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } - bool - operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT - { return _M_node != __x._M_node; } + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } _Base_ptr _M_node; }; @@ -390,29 +390,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __tmp; } - bool - operator==(const _Self& __x) const _GLIBCXX_NOEXCEPT - { return _M_node == __x._M_node; } + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } - bool - operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT - { return _M_node != __x._M_node; } + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } _Base_ptr _M_node; }; - template - inline bool - operator==(const _Rb_tree_iterator<_Val>& __x, - const _Rb_tree_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT - { return __x._M_node == __y._M_node; } - - template - inline bool - operator!=(const _Rb_tree_iterator<_Val>& __x, - const _Rb_tree_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT - { return __x._M_node != __y._M_node; } - void _Rb_tree_insert_and_rebalance(const bool __insert_left, _Rb_tree_node_base* __x, @@ -1616,56 +1604,38 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } #endif // C++17 + + friend bool + operator==(const _Rb_tree& __x, const _Rb_tree& __y) + { + return __x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin()); + } + + friend bool + operator<(const _Rb_tree& __x, const _Rb_tree& __y) + { + return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); + } + + friend bool _GLIBCXX_DEPRECATED + operator!=(const _Rb_tree& __x, const _Rb_tree& __y) + { return !(__x == __y); } + + friend bool _GLIBCXX_DEPRECATED + operator>(const _Rb_tree& __x, const _Rb_tree& __y) + { return __y < __x; } + + friend bool _GLIBCXX_DEPRECATED + operator<=(const _Rb_tree& __x, const _Rb_tree& __y) + { return !(__y < __x); } + + friend bool _GLIBCXX_DEPRECATED + operator>=(const _Rb_tree& __x, const _Rb_tree& __y) + { return !(__x < __y); } }; - template - inline bool - operator==(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, - const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) - { - return __x.size() == __y.size() - && std::equal(__x.begin(), __x.end(), __y.begin()); - } - - template - inline bool - operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, - const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) - { - return std::lexicographical_compare(__x.begin(), __x.end(), - __y.begin(), __y.end()); - } - - template - inline bool - operator!=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, - const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) - { return !(__x == __y); } - - template - inline bool - operator>(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, - const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) - { return __y < __x; } - - template - inline bool - operator<=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, - const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) - { return !(__y < __x); } - - template - inline bool - operator>=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, - const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) - { return !(__x < __y); } - template inline void diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index a885859592b..6821fc561e4 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -519,7 +519,7 @@ namespace __debug for (_Base_const_iterator __victim = __first.base(); __victim != __last.base(); ++__victim) { - _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), _M_message(__gnu_debug::__msg_valid_range) ._M_iterator(__first, "first") ._M_iterator(__last, "last")); diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index 50500d66f70..d16ed47ab74 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -400,7 +400,7 @@ namespace __debug for (_Base_const_iterator __victim = __first.base(); __victim != __last.base(); ++__victim) { - _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), _M_message(__gnu_debug::__msg_valid_range) ._M_iterator(__first, "first") ._M_iterator(__last, "last")); diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index d292a14ca8c..bf154ecad6e 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -367,7 +367,7 @@ namespace __debug for (_Base_const_iterator __victim = __first.base(); __victim != __last.base(); ++__victim) { - _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), _M_message(__gnu_debug::__msg_valid_range) ._M_iterator(__first, "first") ._M_iterator(__last, "last")); diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index ed75f0f174f..c406fb424f4 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -379,7 +379,7 @@ namespace __debug for (_Base_const_iterator __victim = __first.base(); __victim != __last.base(); ++__victim) { - _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), _M_message(__gnu_debug::__msg_valid_range) ._M_iterator(__first, "first") ._M_iterator(__last, "last"));