This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix stable_sort to work on iterators returning rvalue


On 05/25/2012 10:42 PM, François Dumont wrote:
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 ?
Patch looks pretty good to me. It would be great if the usual friends of libstdc++ could also have a look, in particular Chris (if I remember correctly he invented this stuff)

Thanks,
Paolo.

PS: as a very minor nit, remember the bool test variable in test01.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]