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] |
2012/5/17 François Dumont<frs.dumont@gmail.com>:Ok for how to have iter_swap work with move_iterator, users must grant the necessary swap overload. But what about the other algos like stable_sort I have tested at first ? Shouldn't they be adapted to work with move_iterator ?Hi
While working on removal of code duplications in algos implementation I challenge them with move_iterator. I started with stable_sort and it doesn't compile. I summarize the problem to the fact that iter_swap can't be used on move_iterator. As, in C++11, iter_swap simply forward to swap(*__a, *__b) it is normal that it can't accept rvalue but shouldn't iter_swap be adapted to accept move_iterator ?Yes, when the referenced type (or the iterator's reference) provides a swap overload that accepts rvalues. Remember that move_iterator will produce an rvalue on dereference, this rvalue is provided to the swap overload that is found by ADL. Given your description I would expect that the test type does not provide a swap overload accepting rvalues, thus the std::swap is selected, but cannot accept the arguments.
Agree but the compiler message do not show the '&&', this is especially obvious in:
Yes, but move_iterator<>::reference is value_type&&.Why is the comipiler talking about a call to swap on move_iterator<greedy_ops::X*>::value_type. It should be on the return type of move_iterator operator* which is move_iterator<>::reference, no ?
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |