is there strided iterator already available somewhere?

hello, is there strided iterator already available somewhere? iter = vec.begin(); std::advance(iter,offset) for(unsigned int i=0; i<(vec.size()-offset)/stride; ++i){ /* do something with iter */ std::advance(iter,stride) } alternatively, a permutation iterator does not seem very practical here... thanks, e.

Here is mine:

Neal Becker wrote:
Here is mine:
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi, helpful, thanks. Would be nice if accessible from the sanbox or vault. if the distance(base_begin, base_end) is not a multiple of stride, i'm wondering if there are any implications (if the iterator_base is not trivial) to defining e = make_strided_iterator(base_end,stride), and using the usual i++<e in a loop. if there are, i'm thinking maybe something like this? strided_iterator<iterator_base> make_end_strided_iterator(iterator_base b,iterator_base e,stride){ i = b ee = e; std::size_t d = (std::distance(i,ee)-1)/stride; d *= stride; ee = i; std::advance(ee,d+1); return make_strided_iterator(ee,stride); }
participants (2)
-
e r
-
Neal Becker