0

I am trying to make a vector of iterators in my C++ application:

std::vector<std::list<std::shared_ptr<SelfDefinedType>>::iterator> edge_iters;

SelfDefinedType is a class I declared somewhere above this snippet.

I must admit this organization is a bit complicated, but there is a hierarchical structure to the templating.

I am getting the following compile-time error compiling with C++11.

App.hpp:563:48: error: type/value mismatch at argument 1 in template 
parameter list for ‘template<class _Tp, class _Alloc> class std::vector’

What does this mean? It seems to be treating std::list<std::shared_ptr<SelfDefinedType>>::iterator as a value instead of a type. Why?

I tried to add spaces to the beginning and end brackets to no avail. I also tried to use typedef to suppress compilation errors, which didn't work.

dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206

2 Answers2

3

You should specify that std::list<std::shared_ptr<SelfDefinedType>>::iterator is a type.

Here iterator is nested inside std::list<std::shared_ptr<SelfDefinedType>> and SelfDefinedType is a template parameter.

The parser assumes iterator is not a type, unless you tell it explicitly with typename.

To solve the error (note the typename):

std::vector<typename std::list<std::shared_ptr<SelfDefinedType>>::iterator> edge_iters;
Grigorii Chudnov
  • 3,046
  • 1
  • 25
  • 23
0

I'm not sure this is the issue but this can be understood as operator>> by your compiler.

Try std::vector< std::list< std::shared_ptr< SelfDefinedType > >::iterator > edge_iters;

Kamouth
  • 134
  • 2
  • 9