Explain for (int x:y)

Could someone please explain to me in detail how this works. for(int x : y). Basically the use of the colon, ':'.

1
2
3
4
5
for(auto it = std::begin(y); it != std::end(y); ++it)
{
    int x = *it;
    // inner for loop content ends up here
}
Last edited on
Search the web with "C++11 range-based for-loop".
Topic archived. No new replies allowed.