How to #include hash with ext, tr1, or __gnu_cxx i

2019-08-06 19:29发布

I'm trying to work with the google-sparsehash library and I'd like to include the hash library described in the link,

using ext::hash;  // or __gnu_cxx::hash, or maybe tr1::hash, depending on your OS

and I've tried one of each:

#include <ext/hash>
#include <ext>
#include <__gnu_cxx>
#include <tr1>

which none worked with XCode. I've also "using", where I was told that __gnu_cxx does not contain "hash". How do I describe this library to XCode (3.2.6) on OS X (10.6.8)?

Or more generally, where is this hash function described in a Mac / XCode?

标签: c++ xcode hash map
2条回答
做自己的国王
2楼-- · 2019-08-06 19:54

So far as I can tell, it doesn't seem possible to get at the hash functors without also pulling in definitions for the various hash tables. At least not without fooling around with library internal headers.

Try:

#include <ext/hash_map>
using __gnu_cxx::hash;

or:

#include <tr1/unordered_map>
using std::tr1::hash;
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-08-06 20:09

In C++11:

#include <functional>
using std::hash;

In C++03 with TR1:

#include <tr1/functional>
using std::tr1::hash;
查看更多
登录 后发表回答