I am trying to compile the following code on Linux using gcc 4.2:
#include When I compile this class I receive the following message from gcc:
error: type/value mismatch at argument 2 in template parameter list for ‘template class std::map’
error: expected a type, got ‘std::list,std::allocator > >::iterator’
error: template argument 4 is invalid
I have removed file names and line numbers , but they all refer to the line declaring the map.
When I replace the pair in these expressions with an int or some concrete type, it compiles fine. Can someone please explain to me what I am doing wrong.
Answer
You need to write typename before std::list<...>::iterator, because iterator is a nested type and you're writing a template.
Edit: without the typename, GCC assumes (as the standard requires) that iterator is actually a static variable in list, rather than a type. Hence the "parameter type mismatch" error.
No comments:
Post a Comment