The C++11 introduced ranged-based for loop that is internally implemented using (const) iterators so this:
std::vector vec;
for(std::stri
Yes, that's a valid solution. The underlying data is guaranteed to be contiguous (std::vector is supposed to be a dynamic array, more or less).
n4140 §23.3.6.1 [vector.overview]/1
The elements of a
vectorare stored contiguously, meaning that ifvis avectorwhereTis some type other thanbool, then it obeys the identity&v[n] == &v[0] + nfor all0 <= n < v.size()