Consider the following code:
template <typename Datatype>
class MyClass
{
void doStuff();
template <typename AnotherDatatype>
void doTemplateStuff(AnotherDatatype Argument);
};
template <typename Datatype>
void MyClass<Datatype>::doStuff()
{
}
template <typename Datatype>
template <typename AnotherDatatype>
void MyClass<Datatype>::doTemplateStuff(AnotherDatatype Argument)
{
}
The implementation for the second member function doTemplateStuffwill not compile if I condense it like this:
template <typename Datatype, typename AnotherDatatype>
void MyClass<Datatype>::doTemplateStuff(AnotherDatatype Argument)
{
}
Why is this? Shouldn't the template information be separated by commas, just like putting each typenameon its own line? Or is there some subtle difference that I don’t know about ...?
(Also, if someone might think of a better headline, please let me know.)
source
share