@@ -137,11 +137,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
137137#endif
138138 : _M_current(__i.base()) { }
139139
140- _GLIBCXX_NODISCARD __attribute__ ((__always_inline__))
141- _GLIBCXX_CONSTEXPR
142- __normal_iterator<_Iterator, _Container> _M_const_cast() const
143- { return __normal_iterator<_Iterator, _Container>(_M_current); }
144-
145140 // Forward iterator requirements
146141
147142 _GLIBCXX_NODISCARD __attribute__ ((__always_inline__))
@@ -235,46 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
235230 // provide overloads whose operands are of the same type. Can someone
236231 // remind me what generic programming is about? -- Gaby
237232
238- #ifdef __cpp_lib_three_way_comparison
239- template <typename _IteratorL, typename _IteratorR, typename _Container>
240- [[nodiscard, __gnu__::__always_inline__]]
241- constexpr bool
242- operator ==(const __normal_iterator<_IteratorL, _Container>& __lhs,
243- const __normal_iterator<_IteratorR, _Container>& __rhs)
244- noexcept (noexcept (__lhs.base() == __rhs.base()))
245- requires requires {
246- { __lhs.base () == __rhs.base () } -> std::convertible_to<bool >;
247- }
248- { return __lhs.base () == __rhs.base (); }
249-
250- template <typename _IteratorL, typename _IteratorR, typename _Container>
251- [[nodiscard, __gnu__::__always_inline__]]
252- constexpr std::__detail::__synth3way_t <_IteratorR, _IteratorL>
253- operator <=>(const __normal_iterator<_IteratorL, _Container>& __lhs,
254- const __normal_iterator<_IteratorR, _Container>& __rhs)
255- noexcept (noexcept (std::__detail::__synth3way(__lhs.base(), __rhs.base())))
256- { return std::__detail::__synth3way (__lhs.base (), __rhs.base ()); }
257-
258- template <typename _Iterator, typename _Container>
259- [[nodiscard, __gnu__::__always_inline__]]
260- constexpr bool
261- operator ==(const __normal_iterator<_Iterator, _Container>& __lhs,
262- const __normal_iterator<_Iterator, _Container>& __rhs)
263- noexcept (noexcept (__lhs.base() == __rhs.base()))
264- requires requires {
265- { __lhs.base () == __rhs.base () } -> std::convertible_to<bool >;
266- }
267- { return __lhs.base () == __rhs.base (); }
268-
269- template <typename _Iterator, typename _Container>
270- [[nodiscard, __gnu__::__always_inline__]]
271- constexpr std::__detail::__synth3way_t <_Iterator>
272- operator <=>(const __normal_iterator<_Iterator, _Container>& __lhs,
273- const __normal_iterator<_Iterator, _Container>& __rhs)
274- noexcept (noexcept (std::__detail::__synth3way(__lhs.base(), __rhs.base())))
275- { return std::__detail::__synth3way (__lhs.base (), __rhs.base ()); }
276- #else
277- // Forward iterator requirements
233+ // Forward iterator requirements
278234 template <typename _IteratorL, typename _IteratorR, typename _Container>
279235 _GLIBCXX_NODISCARD __attribute__ ((__always_inline__)) _GLIBCXX_CONSTEXPR
280236 inline bool
@@ -371,7 +327,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
371327 const __normal_iterator<_Iterator, _Container>& __rhs)
372328 _GLIBCXX_NOEXCEPT
373329 { return __lhs.base () >= __rhs.base (); }
374- #endif // three-way comparison
375330
376331 // _GLIBCXX_RESOLVE_LIB_DEFECTS
377332 // According to the resolution of DR179 not only the various comparison
@@ -1378,7 +1333,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
13781333 insert (const_iterator __position, size_type __n, const value_type& __x)
13791334 {
13801335 difference_type __offset = __position - cbegin ();
1381- _M_fill_insert (__position. _M_const_cast () , __n, __x);
1336+ _M_fill_insert (begin () + __offset , __n, __x);
13821337 return begin () + __offset;
13831338 }
13841339#else
@@ -1423,7 +1378,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
14231378 _InputIterator __last)
14241379 {
14251380 difference_type __offset = __position - cbegin ();
1426- _M_insert_dispatch (__position. _M_const_cast () ,
1381+ _M_insert_dispatch (begin () + __offset ,
14271382 __first, __last, __false_type ());
14281383 return begin () + __offset;
14291384 }
@@ -1471,10 +1426,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
14711426 iterator
14721427#if __cplusplus >= 201103L
14731428 erase (const_iterator __position)
1429+ { return _M_erase (begin () + (__position - cbegin ())); }
14741430#else
14751431 erase (iterator __position)
1432+ { return _M_erase (__position); }
14761433#endif
1477- { return _M_erase (__position._M_const_cast ()); }
14781434
14791435 /* *
14801436 * @brief Remove a range of elements.
@@ -1497,10 +1453,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
14971453 iterator
14981454#if __cplusplus >= 201103L
14991455 erase (const_iterator __first, const_iterator __last)
1456+ {
1457+ const auto __beg = begin ();
1458+ const auto __cbeg = cbegin ();
1459+ return _M_erase (__beg + (__first - __cbeg), __beg + (__last - __cbeg));
1460+ }
15001461#else
15011462 erase (iterator __first, iterator __last)
1463+ { return _M_erase (__first, __last); }
15021464#endif
1503- { return _M_erase (__first._M_const_cast (), __last._M_const_cast ()); }
15041465
15051466 /* *
15061467 * @brief Swaps data with another %vector.
0 commit comments