How to # enable hash with ext, tr1 or __gnu_cxx in XCode, C ++

I am trying to work with google-sparsehash library and I would 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 tried one of them:

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


which didn't work with Xcode. I also "used" where I was told that __gnu_cxx does not contain a "hash". How to describe this library for XCode (3.2.6) on OS X (10.6.8)?

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


source to share

2 answers

In C ++ 11:

#include <functional>
using std::hash;


In C ++ 03 with TR1:

#include <tr1/functional>
using std::tr1::hash;




As far as I can tell, it is not possible to get hash functors without pulling definitions for different hash tables. At least not fooled by the internal library headers.


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



#include <tr1/unordered_map>
using std::tr1::hash;




All Articles