
30 Oct
2012
30 Oct
'12
7:12 p.m.
// 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?
The call to distance() will iterate over the range if it's not random-access (or worse, if it's an input range, it will consume it!). A hand-crafted solution could avoid this. Regards, Nate