【发布时间】:2021-07-29 10:16:12
【问题描述】:
我正在尝试使用 MinGW g++(i686-win32-dwarf-rev0,由 MinGW-W64 项目构建)8.1.0 编译此代码
#include <bits/stdc++.h>
using namespace std;
int main()
{
map<int, int> mmap;
mmap[0]=10;
mmap[1]=20;
mmap[2]=30;
mmap[3]=40;
mmap[4]=50;
for(auto [x,y]:mmap){
cout<<x<<"->"<<y<<endl;
}
return 0;
}
用 c++11 标志编译得到这个
E:\Code>g++ temp.cpp -std=c++11
temp.cpp: In function 'int main()':
temp.cpp:89:14: warning: structured bindings only available with -std=c++17 or -std=gnu++17
for(auto [x,y]:mmap){
使用 c++17 标志编译会产生一行又一行的错误。
g++ temp.cpp -std=c++17
【问题讨论】:
-
这能回答你的问题吗? Why should I not #include <bits/stdc++.h>?
-
它支持这个想法。因为没有暗示表明问题出在该特定行上。 cmd 只是因为错误而疯狂,而不是暗示它在包含 bits/stdc++.h 时存在问题。