Мне нужен класс hash_map в C ++ (STL). Основная операция - поместить пару в набор, а затем проверить, существует она или нет.
Я не могу найти пример кода, который делает это, чтобы узнать, правильно ли я заявляю или нет.
Этот компилируется. Но если я добавлю строку:
карта [пись (10, "Привет")] = 10;
тогда это дает много ошибок:
/ usr / include / c ++ / 4.4 / backward / hashtable.h: в функции-члене 'size_t __gnu_cxx :: hashtable :: _ M_bkt_num_key (const _Key &, size_t) const [с _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/backward/hashtable.h:594: создается из 'size_t __gnu_cxx :: hashtable :: _ M_bkt_num (const _Val &, size_t) const [with _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/backward/hashtable.h:1001: создается из 'void __gnu_cxx :: hashtable :: resize (size_t) [с _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/backward/hashtable.h:789: создается из '_Val & __gnu_cxx :: hashtable :: find_or_insert (const _Val &) [с _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/backward/hash_map:216: создается из '_Tp & __gnu_cxx :: hash_map :: operator [] (постоянное имя __gnu_cxx :: hashtable, _Key, _HashFn, std :: _ Select1st>, _EqualKey, _AqualKey, :: key_type &) [с _Key = std :: pair, std :: allocator>>, _Tp = int, _HashFn = __gnu_cxx :: hash, std :: allocator>>>, _EqualKey = eqpis, _Alloc = std :: allocator] '
x.cpp: 18: создается здесь
/usr/include/c++/4.4/backward/hashtable.h:590: ошибка: нет совпадения для вызова '(const __gnu_cxx :: hash, std :: allocator>>>) (const std :: pair, std :: распределитель>> &) '