GodLovesUGaius GodLovesUGaius - 8 months ago 44
C++ Question

Syntax error for identifier 'iterator'

The following code throws two compiler errors in VS 2013:

  1. The template function definition throws

    error C2061: syntax error : identifier '

  2. The specialization of that template function throws

    error C2912: explicit specialization '
    double getFillIn<double,double>(fillInOptions,double,std::_Tree_iterator<std::_Tree_val<std::_Tree_simple_types<std::pair<const _Kty,_Ty>>>>,inputLoader *,va_list)
    ' is not a specialization of a function template

Can anyone please explain why? I'm fairly certain the second error is just a consequence of the first, but I don't understand why it can't figure out that

#include <map>

template <typename T> class table {

template <typename S, typename T>
void f(S s, std::map<S, table<T>*>::iterator it);


Because the compiler doesn't yet know the type of std::map<S, table<T>*>, it can't yet know that std::map<S, table<T>*>::iterator is a type (it could be a member). You need to tell it that it will be a type:

template <typename S, typename T>
void f(S s, typename std::map<S, table<T>*>::iterator it);