The correct style would be to use the appropriate algorithm for the task at hand. You should use the range-for loop only when you want to do a
for (auto const & i : v) // std::for_each
or a
for (auto & i : v) // std::transform
In this case, if you want to compare adjacent elements, you should use one of the std::adjacent...
algorithms.
If you just want to find a position in the vector according to a predicate that compares adjacent elements, use
std::adjacent_find(std::begin(v), std::end(v));
If you want to transform a range according to a predicate that uses adjacent elements, use
std::adjacent_difference(std::begin(v), std::end(v), std::begin(v));
You should use a conventional for-loop only when there isn't an appropriate algorithm you can use (this happens quite rarely).
On a side note, your conventional for-loop has UB if the input range is empty. With -Wall
the compiler will point out the problematic code. Prefer to write it like this
for(int i = 0; i < static_cast<int>(vec.size()) - 1; ++i){
if(vec[i] < vec[i+1])
// ...
}
Or like this, if you want to avoid casting
for(auto i = 0u; i + 1 < vec.size(); ++i){
if(vec[i] < vec[i+1])
// ...
}