iterator as a template type

Hi,

I have the following type definition:

1
2
3
4
5
6
template<class Key, class T>
class Cache
{
private:
    std::unordered_map <Key, std::list< CacheElement<Key, T> >::iterator > _cacheHash;
}


While compiling, i get the following error message;
1
2
3
Error: template argument for template type parameter must be a type; did you forget 'typename'?
    std::unordered_map <Key, std::list< CacheElement<Key, T> >::iterator > _cacheHash;
                             ^


Whats the correct syntax?

Thanks
Last edited on
You need to use typename to tell the compiler that std::list<CacheElement<Key, T>>::iterator is type.

 
std::unordered_map <Key, typename std::list< CacheElement<Key, T> >::iterator > _cacheHash;

JLBorges has written a good explanation for why it is needed: http://www.cplusplus.com/forum/beginner/103508/#msg557627
Topic archived. No new replies allowed.