[gcc r15-5908] libstdc++: Stop using _Self typedefs in std::list iterators
Jonathan Wakely
redi@gcc.gnu.org
Tue Dec 3 21:36:05 GMT 2024
https://gcc.gnu.org/g:5f02a4f5c66df222ca8db12cde510c387a962c2d
commit r15-5908-g5f02a4f5c66df222ca8db12cde510c387a962c2d
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Nov 12 17:01:59 2024 +0000
libstdc++: Stop using _Self typedefs in std::list iterators
We can just use the injected-class-name instead of defining a new name.
That seems simpler.
libstdc++-v3/ChangeLog:
* include/bits/stl_list.h (_List_iterator): Remove _Self typedef
and just use injected-class-name instead.
(_List_const_iterator): Likewise.
Diff:
---
libstdc++-v3/include/bits/stl_list.h | 40 +++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index dfdab6e511a9..db6b31fdc166 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -255,7 +255,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp>
struct _List_iterator
{
- typedef _List_iterator<_Tp> _Self;
typedef _List_node<_Tp> _Node;
typedef ptrdiff_t difference_type;
@@ -271,7 +270,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_List_iterator(__detail::_List_node_base* __x) _GLIBCXX_NOEXCEPT
: _M_node(__x) { }
- _Self
+ _List_iterator
_M_const_cast() const _GLIBCXX_NOEXCEPT
{ return *this; }
@@ -286,45 +285,47 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
operator->() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Node*>(_M_node)->_M_valptr(); }
- _Self&
+ _List_iterator&
operator++() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_next;
return *this;
}
- _Self
+ _List_iterator
operator++(int) _GLIBCXX_NOEXCEPT
{
- _Self __tmp = *this;
+ _List_iterator __tmp = *this;
_M_node = _M_node->_M_next;
return __tmp;
}
- _Self&
+ _List_iterator&
operator--() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_prev;
return *this;
}
- _Self
+ _List_iterator
operator--(int) _GLIBCXX_NOEXCEPT
{
- _Self __tmp = *this;
+ _List_iterator __tmp = *this;
_M_node = _M_node->_M_prev;
return __tmp;
}
_GLIBCXX_NODISCARD
friend bool
- operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+ operator==(const _List_iterator& __x,
+ const _List_iterator& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node == __y._M_node; }
#if __cpp_impl_three_way_comparison < 201907L
_GLIBCXX_NODISCARD
friend bool
- operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+ operator!=(const _List_iterator& __x,
+ const _List_iterator& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; }
#endif
@@ -340,7 +341,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp>
struct _List_const_iterator
{
- typedef _List_const_iterator<_Tp> _Self;
typedef const _List_node<_Tp> _Node;
typedef _List_iterator<_Tp> iterator;
@@ -376,45 +376,47 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
operator->() const _GLIBCXX_NOEXCEPT
{ return static_cast<_Node*>(_M_node)->_M_valptr(); }
- _Self&
+ _List_const_iterator&
operator++() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_next;
return *this;
}
- _Self
+ _List_const_iterator
operator++(int) _GLIBCXX_NOEXCEPT
{
- _Self __tmp = *this;
+ _List_const_iterator __tmp = *this;
_M_node = _M_node->_M_next;
return __tmp;
}
- _Self&
+ _List_const_iterator&
operator--() _GLIBCXX_NOEXCEPT
{
_M_node = _M_node->_M_prev;
return *this;
}
- _Self
+ _List_const_iterator
operator--(int) _GLIBCXX_NOEXCEPT
{
- _Self __tmp = *this;
+ _List_const_iterator __tmp = *this;
_M_node = _M_node->_M_prev;
return __tmp;
}
_GLIBCXX_NODISCARD
friend bool
- operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+ operator==(const _List_const_iterator& __x,
+ const _List_const_iterator& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node == __y._M_node; }
#if __cpp_impl_three_way_comparison < 201907L
_GLIBCXX_NODISCARD
friend bool
- operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+ operator!=(const _List_const_iterator& __x,
+ const _List_const_iterator& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; }
#endif
More information about the Libstdc++-cvs
mailing list