vector (vector<>::cbegin()): Use C++11 direct initialization.

2018-10-15  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/vector (vector<>::cbegin()): Use C++11 direct
	initialization.
	(vector<>::cend()): Likewise.
	(vector<>::emplace(const_iterator, _Args&&...)): Likewise and use
	consistent iterator comparison.
	(vector<>::insert(const_iterator, size_type, const _Tp&)): Likewise.
	(vector<>::insert(const_iterator, _InputIterator, _InputIterator)):
	Likewise.
	(vector<>::erase(const_iterator)): Likewise.
	(vector<>::erase(const_iterator, const_iterator)): Likewise.

From-SVN: r265156
This commit is contained in:
François Dumont 2018-10-15 05:24:51 +00:00
parent 524af591fd
commit 4b186707ee
2 changed files with 26 additions and 10 deletions

View File

@ -1,3 +1,16 @@
2018-10-15 François Dumont <fdumont@gcc.gnu.org>
* include/debug/vector (vector<>::cbegin()): Use C++11 direct
initialization.
(vector<>::cend()): Likewise.
(vector<>::emplace(const_iterator, _Args&&...)): Likewise and use
consistent iterator comparison.
(vector<>::insert(const_iterator, size_type, const _Tp&)): Likewise.
(vector<>::insert(const_iterator, _InputIterator, _InputIterator)):
Likewise.
(vector<>::erase(const_iterator)): Likewise.
(vector<>::erase(const_iterator, const_iterator)): Likewise.
2018-10-12 Jonathan Wakely <jwakely@redhat.com> 2018-10-12 Jonathan Wakely <jwakely@redhat.com>
Initial commit of Networking TS implementation. Initial commit of Networking TS implementation.

View File

@ -328,11 +328,11 @@ namespace __debug
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
const_iterator const_iterator
cbegin() const noexcept cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); } { return { _Base::begin(), this }; }
const_iterator const_iterator
cend() const noexcept cend() const noexcept
{ return const_iterator(_Base::end(), this); } { return { _Base::end(), this }; }
const_reverse_iterator const_reverse_iterator
crbegin() const noexcept crbegin() const noexcept
@ -521,7 +521,7 @@ namespace __debug
{ {
__glibcxx_check_insert(__position); __glibcxx_check_insert(__position);
bool __realloc = this->_M_requires_reallocation(this->size() + 1); bool __realloc = this->_M_requires_reallocation(this->size() + 1);
difference_type __offset = __position.base() - _Base::begin(); difference_type __offset = __position.base() - _Base::cbegin();
_Base_iterator __res = _Base::emplace(__position.base(), _Base_iterator __res = _Base::emplace(__position.base(),
std::forward<_Args>(__args)...); std::forward<_Args>(__args)...);
if (__realloc) if (__realloc)
@ -529,7 +529,7 @@ namespace __debug
else else
this->_M_invalidate_after_nth(__offset); this->_M_invalidate_after_nth(__offset);
this->_M_update_guaranteed_capacity(); this->_M_update_guaranteed_capacity();
return iterator(__res, this); return { __res, this };
} }
#endif #endif
@ -542,7 +542,8 @@ namespace __debug
{ {
__glibcxx_check_insert(__position); __glibcxx_check_insert(__position);
bool __realloc = this->_M_requires_reallocation(this->size() + 1); bool __realloc = this->_M_requires_reallocation(this->size() + 1);
difference_type __offset = __position.base() - _Base::begin(); difference_type __offset
= __position.base() - __position._M_get_sequence()->_M_base().begin();
_Base_iterator __res = _Base::insert(__position.base(), __x); _Base_iterator __res = _Base::insert(__position.base(), __x);
if (__realloc) if (__realloc)
this->_M_invalidate_all(); this->_M_invalidate_all();
@ -577,7 +578,7 @@ namespace __debug
else else
this->_M_invalidate_after_nth(__offset); this->_M_invalidate_after_nth(__offset);
this->_M_update_guaranteed_capacity(); this->_M_update_guaranteed_capacity();
return iterator(__res, this); return { __res, this };
} }
#else #else
void void
@ -623,7 +624,7 @@ namespace __debug
else else
this->_M_invalidate_after_nth(__offset); this->_M_invalidate_after_nth(__offset);
this->_M_update_guaranteed_capacity(); this->_M_update_guaranteed_capacity();
return iterator(__res, this); return { __res, this };
} }
#else #else
template<class _InputIterator> template<class _InputIterator>
@ -661,7 +662,8 @@ namespace __debug
#endif #endif
{ {
__glibcxx_check_erase(__position); __glibcxx_check_erase(__position);
difference_type __offset = __position.base() - _Base::begin(); difference_type __offset
= __position.base() - __position._M_get_sequence()->_M_base().begin();
_Base_iterator __res = _Base::erase(__position.base()); _Base_iterator __res = _Base::erase(__position.base());
this->_M_invalidate_after_nth(__offset); this->_M_invalidate_after_nth(__offset);
return iterator(__res, this); return iterator(__res, this);
@ -680,7 +682,8 @@ namespace __debug
if (__first.base() != __last.base()) if (__first.base() != __last.base())
{ {
difference_type __offset = __first.base() - _Base::begin(); difference_type __offset =
__first.base() - __first._M_get_sequence()->_M_base().begin();
_Base_iterator __res = _Base::erase(__first.base(), _Base_iterator __res = _Base::erase(__first.base(),
__last.base()); __last.base());
this->_M_invalidate_after_nth(__offset); this->_M_invalidate_after_nth(__offset);
@ -688,7 +691,7 @@ namespace __debug
} }
else else
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
return begin() + (__first.base() - cbegin().base()); return { _Base::begin() + (__first.base() - _Base::cbegin()), this };
#else #else
return __first; return __first;
#endif #endif