Subject: Re: [boost] [move] [range] move algorithm (was: interest: the pass-by-value...)
From: Eric Niebler (eniebler_at_[hidden])
Date: 2014-02-18 20:51:21
On 02/18/2014 10:30 AM, Neil Groves wrote:
> On Tue, Feb 18, 2014 at 5:32 PM, Eric Niebler <eniebler_at_[hidden]> wrote:
>> On 02/18/2014 09:16 AM, Adam Wulkiewicz wrote:
>>> Hi Eric,
>>> Eric Niebler wrote:
>>>> On 02/15/2014 02:17 PM, Adam Wulkiewicz wrote:
>>>>> There is already boost::move_iterator in Boost.Move
>>>> Please make sure that move iterators and ranges are Input and not
>>>> anything else, regardless of what the standard says. The standard is
>>>> dangerously wrong in this regard.
>>> Thanks for the advice. It's because the user might by mistake go through
>>> some elements more than once which would result in some number of moves
>>> from the same element or do you have something more surprising in mind?
>> That's it precisely. And using move iterators in standard algorithms
>> that assume anything other than Input is pretty much guaranteed to make
>> you very unhappy.
> I agree that many scenarios would end in much unhappiness! I disagree that
> unhappiness is pretty much guaranteed. I believe there are valid scenarios
> that would be broken by increasing the requirements to demand single-pass
> traversal. The most common case that I think would be broken in my own code
> is where I am using a random-access iterator to stride.
Why in the world does a stride iterator need to be random-access? Here
is a strided range adaptor that works with input iterators:
It's not even hard.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk