problem hash_map pointers

Hello everybody,

I come here because I cannot find a solution to my problem after very long time of thinking and searching for solutions on the web.

I need to use the hash_map class but with pointer based template parameters. When I use operator[], I get an erreor message.



Here is the code:

int main(int argc, char *argv[])
{
hash<char*,int*> tab;
char c;
tab[&c];
}

template <typename K, typename T>
class hash : __gnu_cxx::hash_map<K*,T*>
{
public:
T* operator[] (K k)
{
this->__gnu_cxx::hash_map<K*,T*>::operator[](k);
}
};



here is the error message:
no matching function for call to `hash<char*, int*>::operator[](char*&)'

candidates are: _Tp& __gnu_cxx::hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc>::operator[](const typename __gnu_cxx::hashtable<std::pair<const _Key, _Tp>, _Key, _HashFcn, std::_Select1st<std::pair<const _Key, _Tp> >, _EqualKey, _Alloc>::key_type&) [with _Key = char**, _Tp = int**, _HashFcn = __gnu_cxx::hash<char**>, _EqualKey = std::equal_to<char**>, _Alloc = std::allocator<int**>]



I tried using a lot of different combinaisons, the only one ok for compilator is: class hash : __gnu_cxx::hash_map<K,T>.
Unfortunaltely I cannot declare it like this because I need to replace a library in a program and have minimal changes on this program whitch was using hash_maps with pointers as template parameters in a hash_map.

I hope I was clear enough in explaining my problem. Could someone strong in c++ help me? The more I try, the more I get messed up.

Thank you very much for helping!
Topic archived. No new replies allowed.