Fix stable_sort to work on iterators returning rvalue

François Dumont frs.dumont@gmail.com
Fri May 25 20:42:00 GMT 2012


Hi

     The issues I had when trying to use stable_sort with move_iterator 
was in fact not all coming from a missing swap overload. In fact 
stable_sort do not accept iterators with dereference operator returning 
pure rvalue. I use std::vector<bool>::iterator to illustrate this 
problem. The problem was in fact coming from 
__uninitialized_construct_buf that was taking a lvalue reference. I 
simply modify the function and the underlying helper struct to 
dereference the iterator as late as possible that is to say only when we 
need to pass it to the std::move function.

2012-05-25  François Dumont <fdumont@gcc.gnu.org>

     * include/bits/stl_tempbuf.h (__uninitialized_construct_buf)
     (__uninitialized_construct_buf_dispatch<>::__ucr): Fix to work
     with iterator returning rvalue.
     * testsuite/25_algorithms/stable_sort/3.cc: New.

Tested under x86_64 linux with make check and make CXXFLAGS=-std=c++11 
check.

Ok to commit ?

François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tempbuf.patch
Type: text/x-patch
Size: 4857 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20120525/090ab6da/attachment.bin>


More information about the Libstdc++ mailing list