Boost logo

Boost :

Subject: Re: [boost] [algorithm] adjacent_for_each interest?
From: Dave Abrahams (dave_at_[hidden])
Date: 2013-02-11 12:52:03


on Mon Feb 11 2013, Evgeny Panasyuk <evgeny.panasyuk-AT-gmail.com> wrote:

> 11.02.2013 3:09, Dave Abrahams:
>
>>> In this regard your version at
>>> https://github.com/irh/adjacent_for_each/blob/master/boost/algorithm/adjacent_for_each.hpp
>>> is broken.
>>> Because it advertises to work on InputIterator, but it dereferences
>>> iterator at same position several times. As the result current
>>> implementation is for ForwardIterator.
>>
>> That's incorrect. The mental model for InputIterator is an ephemeral
>> input stream *with a one-element backing buffer*. You are allowed to
>> dereference the same InputIterator multiple times at the same position
>> until that iterator or a copy of it is incremented.
>
> Thanks for correction, I should re-phrase my sentence as:
> "but it dereferences iterator at same position several times *after
> passing to next and/or dereferencing it*" (
> https://github.com/irh/adjacent_for_each/blob/382070171df195afb945f86db442a8634d8d136d/boost/algorithm/adjacent_for_each.hpp
> )

OK, but the last part of that sentence remains irrelevant. It should
end with the word "next."

-- 
Dave Abrahams

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk