
Is there a function in BOOST, given a starting point and a desired size, that returns iterators for a (sub) range? For example, given: a boost::circular_buffer which contains: 1 2 3 4 5 6 7 8 9 10 a starting point which is an iterator pointing to 5 and finally a desired size which is an int s = 4 The result of which would be iterators producing: 5 6 7 8 A possible implementation might be this (but I was hoping there was a BOOST version since I can't find an STD algorithm) template <typename Itr> std::pair<Itr, Itr> getWindowDown(Itr begin, Itr end, Itr start, const int windowSize) { // Down first, then up if need be const Itr bottom = (end - start > windowSize) ? (start + windowSize) : (end); const Itr top = (bottom - begin > windowSize) ? (bottom - windowSize) : (begin); return make_pair(top, bottom); } Thanks, -- View this message in context: http://boost.2283326.n4.nabble.com/Iterator-Range-sub-range-of-a-desired-siz... Sent from the Boost - Users mailing list archive at Nabble.com.