I've came across the following code:
vector<pair<int, int>> vec;
//...
for (auto &[f, s] : vec)
{
//do something with f and s
}
how does this syntax work ([f, s] : vec) and since what standard was it introduced? Can I use it for getting field values from any struct/class or is it something specific to tuple/pairs?
Also, what is the performance impact of this approach?
In C++11 I was using auto in the following way:
for (auto &it : vec)
{
//do something with it.first and it.second
}