I would like to loop over an array of temporary pairs (with specifying as few types as possible)
for (const auto [x, y] : {{1, 1.0}, {2, 1.1}, {3, 1.2}}) {
// ...
}
Is that possible? (I am free to use any C++ standard which is implemented in gcc 11.2)
Currently I am using a workaround using maps which is quite verbose
for (const auto [x, y] : std::map<int, double>{{1, 1.0}, {2, 1.1}, {3, 1.2}}) {
// ...
}