如何摆脱 g++ hash_map 弃用警告?
当我编译我正在编写的使用 hash_map 的 C++ 应用程序时,我在 g++ 4.3.2 上收到此警告:
You are using the deprecated header 。 要消除此警告,请使用 ANSI 标准头文件或使用 hte -Wno-deprecated 编译器标志。
9> #include <ext/hash_map>
什么包括取代这个? 我在谷歌上搜索了一段时间,除了有类似问题的人之外找不到任何东西,但没有解决方案。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的第一个 Google 搜索结果为“g++ hash_map 已弃用 " 带我到一个页面,其中包含要处理的事项列表使用而不是已弃用的标头和类。
对于
hash_map
,该列表建议使用unordered_map
,在
unordered_map
标头中。 该课程是 TR1 的新课程。My very first Google hit for "g++ hash_map deprecated" takes me to a page that includes a list of things to use instead of the deprecated headers and classes.
For
hash_map
, the list suggests usingunordered_map
, in theunordered_map
header. The class is new for TR1.我相信这个新的数据结构被称为
unordered_map
,位于
std::tr1
命名空间中。I believe that that new data structure is called
unordered_map
found in the
std::tr1
namespace.当包含 时,不要忘记添加以下编译器选项; “-std=c++0x”,否则编译器会报错
When including , do not forget to add the following compiler option; "-std=c++0x", otherwise the compiler will report an error