I am trying to define a class with a map of K -> pair of V and iterator of a list of K. This is to implement LRU cache. I got this working with decltype:
template <typename K, typename V> class LRUCache {
std::list<K> q;
typedef decltype(q.begin()) Iterator;
typedef std::pair<V, Iterator> Node;
int max_size;
std::map<const K, Node> m;
}
However, I am not satisfied with using decltype and it all seems brittle when I try to use it. What would be the canonical way of doing this?