[v3] Add missing forward_list<>::splice_after and merge overloads fix splice_after taking a range

François Dumont frs.dumont@gmail.com
Thu Apr 12 21:20:00 GMT 2012


One thing after the other :-)

Here is a patch to fix this issue Paolo. The safe iterator 
_M_valid_range method was considering that a range with different 
iterators and last being a begin one is invalid which is wrong when 
there is a before_begin.

2012-04-12  François Dumont <fdumont@gcc.gnu.org>

     * include/debug/safe_iterator.h (_BeforeBeginHelper<>::__value): Add.
     (_Safe_Iterator<>::_M_is_beginnest()): Add.
     * include/debug/safe_iterator.tcc
     (_Safe_Iterator<>::_M_valid_range): Use latter.
     * include/debug/forward_list (_BeforeBeginHelper<>::__value): Add.
     * testsuite/23_containers/forward_list/debug/splice_after.cc:
     Add check.

Tested in 4.7 branch linux x86_64.

I did this patch in the 4.7 branch because I only had this one ready and 
moreover I think it should be integrated in it.

Ok ?

François


On 04/11/2012 11:57 PM, Jonathan Wakely wrote:
> On 11 April 2012 11:32, Paolo Carlini wrote:
>> Francois, can you please review the debug-mode checks for cases like:
>>
>>     std::forward_list<int>  fl1(1), fl2(1);
>>     fl1.splice_after(fl1.before_begin(), fl2, fl2.before_begin(),
>> fl2.begin());
>>
>> ?
>>
>> I don't think we should error out. We don't for things like:
>>
>>     std::list<int>  fl1(1), fl2(1);
>>     fl1.splice(fl1.begin(), fl2, fl2.begin(), fl2.begin());
>>
>> ie, the source is in both cases just an empty range, not an invalid range.
> btw, in debug mode we should be checking fl1.get_allocator() ==
> fl2.get_allocator() for both forward_list and list.
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_forward_list.patch
Type: text/x-patch
Size: 2670 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120412/842bec59/attachment.bin>


More information about the Libstdc++ mailing list