[patch] safe iterator simplification

François Dumont frs.dumont@gmail.com
Thu Nov 7 21:02:00 GMT 2013


Hi

     Here is a patch to simplify a little safe iterator implementation. 
Returning a sequence pointer from a safe iterator and a const sequence 
pointer from a const safe iterator allows to avoid inconsistent usages 
of iterator like comparing iterator with a const_iterator. This way 
__get_distance can be simplified to only take one type of iterator, 
_M_valid_range is not a template method anymore. I also modified 
_BeforeBeginHelper so that it also generates consistent comparisons of 
iterators.

2013-11-08  François Dumont  <fdumont@gcc.gnu.org>

     * include/debug/safe_iterator.h (_BeforeBeginHelper<>::_S_Is):
     Take only a const safe iterator reference.
     (_BeforeBeingHelper<>::_S_Is_beginnest): Likewise.
     (__get_distance): Take only one type of iterator.
     (_Safe_iterator<>::_M_valid_range<>): Not template anymore.
     (_Safe_iterator<>::_M_get_sequence()): Return pointer to const
     sequence from a const_iterator and a pointer to sequence from an
     iterator.
     * include/debug/safe_iterator.tcc: Adapt.
     * include/debug/safe_local_iterator.h
     (_Safe_local_iterator<>::_M_valid_range<>): Not template anymore.
     (_Safe_local_iterator<>::_M_get_sequence()): Return pointer to
     const sequence from a const_iterator and a pointer to sequence
     from an iterator.
     * include/debug/safe_local_iterator.tcc: Adapt.
     * include/debug/forward_list
     (_BeforeBeginHelpers<std::__debug::forward_list<>>): Adapt.


Tested undex Linux x86_64 debug mode.

Ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: safe_iterator.patch
Type: text/x-patch
Size: 14215 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20131107/c5b79c91/attachment.bin>


More information about the Libstdc++ mailing list