samedi 5 mai 2018

std::make_pair fails to initialize nested template iterator type

I am writing a templated LRU Cache in C++

template <class Key, class Value>
class LRUCache{
public:
    typedef Key key_type;
    typedef Value value_type;
}

and am storing list iterator in a map as

std::pair<value_type, typename std::list<key_type>::iterator> 
value_pair = std::make_pair(value, m_list_.begin());

This fails when I initialize the Value as a templated wrapper.

template <class V> class CacheValue{
}

value_type = CacheValue<std::string>

no matching constructor for initialization of 'std::__1::pair >, std::__1::__list_iterator, void *> >

Not sure why the iterator has a void*

Aucun commentaire:

Enregistrer un commentaire