c++ - 错误 : 'hash_map' is not a member of 'std'

标签 c++ g++ hashmap

<分区>

这是我的“程序”:

#include <string>
#include <ext/hash_map>

int main()
{
    std::hash_map<std::string, int>  myMap;
}

我正尝试在 Red Hat 上用 g++ 编译它。有人可以解释为什么编译器会提示:

错误:“hash_map”不是“std”的成员

最佳答案

hash_map 在不同的命名空间中,即 __gnu_cxx::hash_map。 HashMap 的更新版本是 std::tr1::unordered_map 或自 c++11 std::unordered_map

关于c++ - 错误 : 'hash_map' is not a member of 'std' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18833818/

相关文章:

Java hashmap 到矩阵的转换

c++ - HashMap 和 vector 很慢

c++ - 如何使用 C++ 使用 recv() 函数接收大数据?

c++ - 在已移动的排序数组中找到最小值

c++ - 在Mac mojave上安装的gcc和g++无法正常工作(简装)

c++ - 带有英特尔 C++ 编译器的 Armadillo 错误

c++ - 使用依赖项编译 PIN 工具

c++ - 调试c++ : . ./nptl/sysdeps/unix/sysv/linux/raise.c:没有这样的文件或目录

C++ CMake 找不到 Boost 1.63(使用 CLion IDE)

java - 未知深度java的嵌套 HashMap