【发布时间】:2015-04-28 18:53:29
【问题描述】:
我正在将一些代码从 Visual Studio 移植到 Mingw GCC,我遇到了这种类型
typedef stdext::hash_map<std::string, SubApplication*> SubApplMap;
现在据我了解,这不是标准类型。我遇到了这个thread aand 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
^
关于我可以用什么替换此容器的任何建议?
【问题讨论】:
-
那些
#defines 是个坏主意,你应该做这个工作并将stdext::hash_map替换为std::unordered_map。希望接口足够相似,不会有太多的工作。至于错误,我的猜测是您的代码在其他地方使用了stdext::hash_multimap,而#define stdext std则搞砸了。将该类型替换为std::unordered_multimap
标签: c++ visual-studio gcc dictionary