C++ pair iterator

#1

I have found this kind of iterator form throughout the C++ version:

for (const auto& [next_x, next_y] : … ) {

}

I have tried running it in Visual Studio C++ 2017 but it failed to compile.
I wonder if this is C++17 standard. What is it called?

Thanks.

0 Likes

#2

Indeed, this is C+±17 feature. See https://stackoverflow.com/questions/6963894/how-to-use-range-based-for-loop-with-stdmap

0 Likes