error: 'unordered_set' is not a member of 'std'

error: 'unordered_set' is not a member of 'std'

在 C++ 中,我试图像这样声明一个 unordered_set

std::unordered_set<int> k;

但是显示这个错误:

error: 'unordered_set' is not a member of 'std'

我在使用 MinGW 的 windows 上使用 g++ (GCC) 5.3.0。以下是我已经考虑过的事情:

  1. 通过#include <unordered_set>
  2. 添加头文件
  3. 正在升级 MinGW
  4. 使用标志 -std=gnu++11。 (这不会生成任何可执行文件或错误,不确定它是否执行任何操作)

如何修复它并成功编译我的代码?

使用-std=c++11开关并指定输出文件。

g++ -std=c++11 your_file.cpp -o your_program