我正在尝试使用在 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/