std::map does not compile when value type is template

Hello

This code:
1
2
3
4
template <typename MyT>
inline void myFunc(MyT value) {
    std::map<int, MyT>::iterator myIter;
}


gives this error:
error: expected `;' before "myIter"

but it compiles when I replace 'MyT' with 'int' in the third line, so I think the code is correct.

Can anyone tell me why the map won't accept template types?

Thanks.
Last edited on
That should work. What compiler are you using?
mingw32 with code::blocks
1
2
3
4
template <typename MyT>
inline void myFunc(MyT value) {
    typename std::map<int, MyT>::iterator myIter;
}
I've tryied in visual studio and it compiles indeed, but I need it for mingw, and R0mai's solution works, thanks a lot.
Topic archived. No new replies allowed.