Quantcast
Channel: Iterate over a container with a custom start/end position - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by eerorika for Iterate over a container with a custom start/end position

Is there a better way to achieve this ...A solution using ranges (courtesy of cigien in comments):for (int element : v | ranges::drop_view(1))A solution using spanfor (int element : span(&v[1],...

View Article



Answer by super for Iterate over a container with a custom start/end position

To replicate make_iterator_range you need an object with a begin and end function. Something like this.template <typename T>struct iterator_range { iterator_range(T begin, T end) :...

View Article

Answer by n314159 for Iterate over a container with a custom start/end position

std::for_each is in C++11 and with that you can do:std::for_each(v.begin() + 1, v.end(), [](auto &n) { ... });

View Article

Iterate over a container with a custom start/end position

I'd like to iterate over a container (say a std::vector) but not from the beginning. I am basically trying to replicate boost::make_iterator_range(v.begin() + 1, v.end()).I came up with this:#include...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images