android - 如何在 Android 中使用 unordered_map?

标签 android c++ c++11 hashmap unordered-map

我正在尝试使用在 Android NDK 中定义的 hash_map,但我收到“弃用警告”:

ndk/sources/cxx-stl/gnu-libstdc++/4.6/include/ext/../backward/backward_warning.h:33:2:
error: #warning This file includes at least one deprecated or antiquated header which may 
be removed without further notice at a future date. Please use a non-deprecated interface 
with equivalent functionality instead. For a listing of replacement headers and 
interfaces, consult the file backward_warning.h. To disable this warning use -Wno-
deprecated. [-Werror=cpp]

并且由于“unordered_map”存在于 gnu-libstdc++/4.6/include/以及 gnu-libstdc++/4.6/include/tr1/中,我相信有一种方法可以使用它。

问题是我找不到它。以下哪项是正确的(如果有的话):

#include <tr1/unordered_map.h>

#include <unordered_map>

然后,如何使用它? __gnu_cxx::unordered_map 无法识别...而且我不知道如何找到此信息。

最佳答案

如果您不想/不需要 C++11 支持,您可以使用来自 STLPort 的支持:

// Here we are referencing the stlport one:
#include <unordered_map>
...
std::tr1::unordered_map<int, int> test;

这是因为 STLPort 在 tr1 命名空间中定义了 unordered_map,但 STLPort header 不在任何 /tr1/ 文件夹中。

关于android - 如何在 Android 中使用 unordered_map?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15545283/

相关文章:

android - 添加 firebase 后,所有 com.android.support 库必须使用完全相同的版本规范

c++ - 有没有办法用 ON_CALL 制作模拟函数 "interesting"?

c++ - Qt 菜单栏不显示

C++ std::array 转换

c++ - 从绑定(bind)与 lambda 函数中获取 operator() 的类型

c++ - Variadac 宏将宏应用于所有参数

android - 随着数据库更改,我不断增加对我的可观察对象的重复 onChange 传递

android - libssl 和 libcrypto 的 undefined reference 错误

android - twitter4J 我不知道我是否需要帐户

c++ - LNK2001:未解析的外部符号,当试图从另一个 DLL 调用对象的方法时