我正在将一些代码从 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/