Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / January 2006



Tip: Looking for answers? Try searching our database.

Template Syntax Error in Xcode: parse error before `>' token

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steve@walkereffects.com - 19 Jan 2006 17:58 GMT
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>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.