map<int, string> m = { {1,string("abc")},{2,string("ttt")}, };
for (auto&[a, b] : m)
{
cout << a << b << endl;
}
我知道另一种样式 for (auto &iter : m)
,iter 是每个元素的对。但在这个 auto&[a, b]
中,我是第一次看到它。谁能告诉我用法?
编辑:我的问题是结构化绑定——正如 Eljay 提示的那样,不一定是 std::map 循环。