[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

hash error



Hi,

i'm trying to compile a small piece of code in which i use a hash map
whose keys are strings. 

here are the types i use:

struct eqstr {
  bool operator()( string s1, string s2 ) const {
    return s1 == s2;
  }
};

typedef pair< string, float > char_pair;
typedef list< char_pair > t_list_bp;
typedef pair< string, t_list_bp > hash_elt;

typedef hash_map< string, t_list_bp, hash< string >, eqstr > t_hash_map;


whenever i try to use a string as key for the hashmap, i get this neat
error message:


dvergnau <~/exbgr/sourcen> make
g++  -D"_linux_" -c build_flex.cxx -o build_flex.o
/usr/include/g++-3/stl_hashtable.h: In method `size_t hashtable<_Val, 
_Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>::_M_bkt_num_key (const 
_Key &, unsigned int) const [with _Val = pair<const string, t_list_bp>, 
_Key = string, _HashFcn = hash<string>, _ExtractKey = 
_Select1st<pair<const string, t_list_bp> >, _EqualKey = eqstr, _Alloc = 
allocator<t_list_bp>]':
/usr/include/g++-3/stl_hashtable.h:536:   instantiated from
`hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
_Alloc>::_M_bkt_num (const _Val &, unsigned int) const [with _Val =
pair<const string, t_list_bp>, _Key = string, _HashFcn = hash<string>,
_ExtractKey = _Select1st<pair<const string, t_list_bp> >, _EqualKey =
eqstr, _Alloc = allocator<t_list_bp>]'
/usr/include/g++-3/stl_hashtable.h:930:   instantiated from
`hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>::resize
(unsigned int) [with _Val = pair<const string, t_list_bp>, _Key = string,
_HashFcn = hash<string>, _ExtractKey = _Select1st<pair<const string,
t_list_bp> >, _EqualKey = eqstr, _Alloc = allocator<t_list_bp>]'
/usr/include/g++-3/stl_hashtable.h:744:   instantiated from
`hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
_Alloc>::find_or_insert (const _Val &) [with _Val = pair<const string,
t_list_bp>, _Key = string, _HashFcn = hash<string>, _ExtractKey =
_Select1st<pair<const string, t_list_bp> >, _EqualKey = eqstr, _Alloc =
allocator<t_list_bp>]'
/usr/include/g++-3/stl_hash_map.h:181:   instantiated from `hash_map<_Key,
_Tp, _HashFcn, _EqualKey, _Alloc>::operator[] (typename
hashtable<pair<const _Key, _Tp>, _Key, _HashFcn, _Select1st<pair<const
_Key, _Tp> >, _EqualKey, _Alloc>::key_type &) [with _Key = string, _Tp =
t_list_bp, _HashFcn = hash<string>, _EqualKey = eqstr, _Alloc =
allocator<t_list_bp>]'
build_flex.cxx:132:   instantiated from here
/usr/include/g++-3/stl_hashtable.h:531: no match for call to `(const 
hash<string>) (const basic_string<char, string_char_traits<char>, 
__default_alloc_template<true, 0> > &)'
make: *** [build_flex.o] Error 1

the kind of instruction it shouts on is something like:

posit = (_lex.insert( hash_elt( flex, theList ) )).first;
  or
_lex.erase( flex );
  or
return _lex[ flex ];

where _lex is of type t_hash_map as defined earlier, and flex is a string.

i really can't imagine what the problem may be, so if someone could help
me, i'd be really grateful

thanx

David



__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/