I am having some trouble with an instance variable of a template class. My goal is to store a list of pairs of an integer and an iterator. The iterator is from a list of class B objects. My problem the compiler wants me to declare the type of class B, but for my application, I would like to keep it generic at this point. Is this possible?
template <typename T>
class A {
public:
A() {}
std::pair<int, std::list<B<T>>::iterator> foo; /* Does not compile. See error 1. */
std::list<B<T>>::iterator bar; /* Does not compile. See error 2. */
std::pair<int, std::list<B<int>>::iterator> foo; /* Compiles just fine. */
std::list<B<int>>::iterator bar; /* Compiles just fine. */
ERROR 1: type/value mismatch at argument 2 in template parameter list for ‘template struct std::pair’ std::list>::iterator>
note: expected a type, got ‘std::__cxx11::list >::iterator’
ERROR 2: need ‘typename’ before ‘std::__cxx11::list >::iterator’ because ‘std::__cxx11::list >’ is a dependent scope std::list>::iterator bar;