c++ - gcc 中是否有 stdext::hash_map 的等价物

标签 c++ visual-studio gcc dictionary

我正在将一些代码从 Visual Studio 移植到 Mingw GCC,我遇到了这种类型

typedef stdext::hash_map<std::string, SubApplication*> SubApplMap;

据我了解,这不是标准类型。我遇到了这个 thread一个和this建议通过执行以下操作将其替换为 unordered_map

#include <unordered_map>
#define stdext std
#define hash_map unordered_map

结果我得到以下错误

 error: 'hash_multimap' is not a member of 'std'
 #define stdext std
                 ^

关于我可以用什么替换这个容器有什么建议吗?

最佳答案

代替

typedef stdext::hash_map<std::string, SubApplication*> SubApplMap;

我会一起摆脱 hash_map

using SubApplMap = std::unordered_map<std::string, SubApplication*>;

而不是尝试使用预处理器宏来玩游戏。

请注意,这需要 C++11。

关于c++ - gcc 中是否有 stdext::hash_map 的等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29927605/

相关文章:

c++ - 获取当前时间()不返回正确的时间

visual-studio - 在Visual Studio中,/mtd和/mdd(在代码生成属性部分中)有什么区别

c++ - 减少大型陌生代码库的内存占用

visual-studio - Visual Studio 立即窗口 : how to see more than the first 100 items

visual-studio-2010 - Web 服务器找不到请求的资源 Visual Studio 调试

c - 没有定义实现类过程

c++ - 使用 C++ constexpr 可以创建符号重复吗?

c++ - 在自己的声明中使用类作为模板参数

c++ - 如何在 C++ 中保存 .txt 文件?

c# - 解码 G711 从 C++ 转换为 C#