I define a hash_map<string, string, stringHashFunction> stringHashMap in Ubuntu with GCC. And I promise that stringHashFunction is right, because I can use string to in hash_map correctly
When I call
string a = "sgsg";
string temp = stringHash[a];
the compiler report bugs that:
error: passing ‘const __gnu_cxx::hash_map, std::basic_string, StringHashFunctionStruct>’ as ‘this’ argument of ‘_Tp& __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqualKey, _Alloc>::operator[](const key_type&) [with _Key = std::basic_string, _Tp = std::basic_string, _HashFn = StringHashFunctionStruct, _EqualKey = std::equal_to >, _Alloc = std::allocator >, __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqualKey, _Alloc>::key_type = std::basic_string]’ discards qualifiers [-fpermissive]
Why could this happen? How should I use string to string hashMap?