Comment utiliser unordered_set dans la STL?

Je suis dans le besoin d'un classes hash_map classe en C++(STL). Fonctionnement principal est de mettre de la paire dans la série et de vérifier ensuite si elle existe ou pas.

Je suis incapable de trouver un exemple de code qui fait de savoir si ce que je suis déclaration correctement ou pas.

#include <iostream>
#include <hash_map>

using namespace std;
using namespace __gnu_cxx;

typedef pair<int,string> pis;

struct eqpis {
    bool operator()(pis p1,pis p2) const {
        if(p1==p2) return true;
        return false;
    }
};

int main() {
    hash_map<pis,int,hash<pis>,eqpis> map;
}    

Ce on compile. Mais si j'ajoute la ligne :
carte[pis(10,"bonjour")]=10;
ensuite, il donne beaucoup d'erreurs:

/usr/include/c++/4.4/précédent/table de hachage.h: En fonction de membre ‘size_t __gnu_cxx::table de hachage::_M_bkt_num_key(const _Key&, size_t) const [avec _Val = std::pair, std::allocator > >, int>, _Key = std::pair, std::allocator > >, _HashFcn = __gnu_cxx::hash, std::allocator > > >, _ExtractKey = std::_Select1st, std::allocator > >, int> >, _EqualKey = eqpis, _Alloc = std::allocator]’:
/usr/include/c++/4.4/précédent/table de hachage.h:594: instancié à partir de ‘size_t __gnu_cxx::table de hachage::_M_bkt_num(const _Val&, size_t) const [avec _Val = std::pair, std::allocator > >, int>, _Key = std::pair, std::allocator > >, _HashFcn = __gnu_cxx::hash, std::allocator > > >, _ExtractKey = std::_Select1st, std::allocator > >, int> >, _EqualKey = eqpis, _Alloc = std::allocator]’
/usr/include/c++/4.4/précédent/table de hachage.h:1001: instanciés à partir de " void __gnu_cxx::table de hachage::resize(size_t) [avec _Val = std::pair, std::allocator > >, int>, _Key = std::pair, std::allocator > >, _HashFcn = __gnu_cxx::hash, std::allocator > > >, _ExtractKey = std::_Select1st, std::allocateur > >, int> >, _EqualKey = eqpis, _Alloc = std::allocator]’
/usr/include/c++/4.4/précédent/table de hachage.h:789: instancié à partir de ‘_Val& __gnu_cxx::table de hachage::find_or_insert(const _Val&) [avec _Val = std::pair, std::allocator > >, int>, _Key = std::pair, std::allocator > >, _HashFcn = __gnu_cxx::hash, std::allocator > > >, _ExtractKey = std::_Select1st, std::allocator > >, int> >, _EqualKey = eqpis, _Alloc = std::allocator]’
/usr/include/c++/4.4/arrière/classes hash_map:216: instancié à partir d' ‘_Tp& __gnu_cxx::classes hash_map::operator[](const typename __gnu_cxx::table de hachage, _Key, _HashFn, std::_Select1st >, _EqualKey, _Alloc>::key_type&) [avec _Key = std::pair, std::allocator > >, _Tp = int, _HashFn = __gnu_cxx::hash, std::allocator > > >, _EqualKey = eqpis, _Alloc = std::allocator]’
x.rpc:18: instancié à partir d'ici
/usr/include/c++/4.4/précédent/table de hachage.h:590: error: no match for call to ‘(const __gnu_cxx::hash, std::allocator > > >) (const std::pair, std::allocator > >&)’

Grâce

OriginalL'auteur user855 | 2009-11-30