On Tue, Oct 30, 2012 at 4:50 PM, David Kimmel <davidwkimmel@gmail.com> wrote:
I tried it out, yes you can get make_iterator_range with next to work. I like boost::next but for what I wanted it does not seem to work appropriately. Your example of "make_iterator_range(boost::next(b.begin, wSize), v.end())" will only skip the first "wSize" elements. What I want is a range that contains at most wSize elements (if possible) - taking them from after (and containing) a start index.
Even my second attempt with this approach (commented out lines) does not work because next does not check to see if it is past end. Perhaps if there is a "min" method I could pass the "boost::next(v.begin() + (start-1), window)" and "v.end()".
typedef vector<int> Vector;Vector v = { 1, 2, 3, 4, 5, 6, 7, 8 , 9, 10, 11 };const int start = 10;const int window = 4;auto r = boost::make_iterator_range(boost::next(v.begin(), start-1), v.end());auto r2 = boost::make_iterator_range(boost::prior(r.end(), window), r.end());// auto r = boost::make_iterator_range(v.begin() + (start-1), boost::next(v.begin() + (start-1), window) );// auto r2 = boost::make_iterator_range(boost::prior(r.end(), window), r.end());