On 15/10/18 07:23 +0200, François Dumont wrote:
This patch extend usage of C++11 direct initialization in
__debug::vector and makes some calls to operator - more consistent.
Note that I also rewrote following expression in erase method:
- return begin() + (__first.base() - cbegin().base());
+ return { _Base::begin() + (__first.base() - _Base::cbegin()), this };
The latter version was building 2 safe iterators and incrementing 1
with the additional debug check inherent to such an operation
whereas the new version just build 1 safe iterator with directly the
expected offset.
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.
Tested under Linux x86_64 Debug mode and committed.
This test fails now:
#define _GLIBCXX_DEBUG
#include <list>
int main()
{
std::list<int> l{11, 11, 11, 12, 12, 12, 13, 13, 13};
auto m = std::next(l.begin(), 7);
l.erase(l.begin(), m);
if (l.size() != 2)
throw 1;
}