On Tue, Oct 30, 2012 at 7:12 PM, Nathan Ridge <zeratul976@hotmail.com> wrote:
The call to distance() will iterate over the range if it's not random-access
> // General solution for all iterator types - assume that source here is
> v from your example
> auto r = boost::make_iterator_range(
> boost::next(boost::begin(source), start - 1),
> boost::next(boost::begin(source), std::min(start - 1 + window,
> static_cast<int>(boost::distance(source))))
> );
>
> I'm not seeing a problem. Am I misunderstanding your question?
(or worse, if it's an input range, it will consume it!).
A hand-crafted solution could avoid this.
Regards,
Nate