Let's say I have a vector of numbers:
std::vector< int > v{ 1, 2, 3, 4 };
I want to iterate over the vector and operate on two at a time; that is, I want to operate on:
(1,2),(2,3), and(3,4).
I know there is a way to do this using Eric Neibler's range-v3 library (slated to be in C++20), but I can't remember the exact sequence of commands.
I could do this using iterators
for( auto begin = v.begin(); begin != (v.end()-1); begin++ ){
// Do something with *begin and *(begin+1)
}
Using the range-v3 library would make this so much more elegant and readable. I just can't remember what the command is.