I'm porting some code over from Codewarrior and have run into a problem
with method templates. I have a class with a template method, which
passes the typename to another template method of another class object.
So in the code below, the mBuffer object has a template method Create
which is a template defined in the same way as this method. But Xcode
gives me a compile error:
template <typename T>
bool Setup() {
if(!mBuffer) {
if(!mBuffer.Create<T>()) { // error: parse error before `>' token
return false;
}
}
return true;
}
This same code compiles fine in Codewarrior and I can't figure out what
I'm missing. It just seems not to like 'Create<T>'. I have tried
'Create<typename T>' but that doesn't work either.
Does anyone know the magic trick to getting Xcode to like this?
Thanks in advance,
Steven Walker
steve@walkereffects.com - 19 Jan 2006 18:04 GMT
I found the answer. For some reason Xcode needs to be told explicitly
that the method is a template:
mBuffer.template Create<T>