1

Possible Duplicate:
Where and why do I have to put the “template” and “typename” keywords?

Im using g++4.6 and I tried to template my class based on the char type used, but my variables arent only chars but also strings of those chars. So I tried something like this:

template<typename T>
class Node
//... 
//constructor
Node(std::basic_string<T> str, std::basic_string<T>::iterator it)
{
}
//usage 
Node<char16_t> start;

but I get ‘std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_Tp1> >::iterator’ is not a type
When I replace second T in the constructor arg list to be char16_t it compiles.

Community
  • 1
  • 1
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277

1 Answers1

6

Why isn't your constructor also called FSDNode?

std::basic_string<T>::iterator is a dependent type, since it depends on template paramter T. So you need to add typename to the argument type.

FSDNode(std::basic_string<T> str, typename std::basic_string<T>::iterator it)
{
}
Praetorian
  • 106,671
  • 19
  • 240
  • 328