c++ - CRTP error with XCode 4.5.2 - Parse Issue, expected expression -


I'm using something to implement, but stuck on an error in XCode 4.5.2. The following code is a simplified version that still replicates the error. It is on the line where the method api :: Enable is defined and there is something with the fact that when there is no code when Api :: Enable Call it-> T: Enable

  enum enum {FOO, BAR, BAZ,}; Template & lt; Typename T & gt; Class AP {Public: Template & lt; Enum E, bool On & gt; Enable Zero () {static_cast & lt; T * & gt; (This) - & gt; Enabled & lt; E, on & gt; ();}}; Class APiIPL: Public API & lt; APIIML & gt; {Public: Template & lt; Enum E, bool On & gt; Enable Zero () {}}; Int main (int argc, const char * argv []) {ApiImpl clsApi; clsApi.Enable & lt; FOO, true & gt; (); Return 0; }   

Here is a screenshot of error in Xcode:. I get the same error that I use "apple llv compiler 4.1" or "llmm gcc 4.2". MSVC Express 2010 compiles without error.

Note that adding function parameters removes the error. The following collection is correct:

  enum enum {FOO, BAR, BAZ,}; Template & lt; Typename T & gt; Class AP {Public: Template & lt; Enum E, bool On & gt; Zero enabled (unsigned int x) {static_cast & lt; T * & gt; (This) - & gt; Enabled & lt; E, on & gt; (X);}}; Class APiIPL: Public API & lt; APIIML & gt; {Public: Template & lt; Enum E, bool On & gt; Enable Zero (unsigned int) {}}; Int main (int argc, const char * argv []) {APIIMPL CLSAP; ClsApi.Enable & lt; FOO, true & gt; (0); Return 0; }    

To resolve the dependent template, you should see the template Keywords should use name:

  template & lt; Enum E, bool on & gt; Enable Zero () {static_cast & lt; T * & gt; (This) - & gt; Template & lt; E, on & gt; (); }   

C ++ 11, [temp.names] / 4 :

When the name of a member template expert Appears later or - & gt; Object expression in postfix-expression or in a qualified-id, and postfix-expression object expression type-dependent or in qualified-id, nested-name-space refers to a dependent type, but name current instant ( 14.6.2.1), the member template name should be prefixed by the keyword template. Otherwise the name is named non-template.

If is enabled () for example template & lt; Typename T & gt; Enable Zero () {} , then TIFF shows an error: Error: Use the 'template' keyword to treat 'enabled' as the dependent template name .

I do not know why it produces irrelevant messages in your case (when there are no template logic). I think this bug can be posted as a report. (I was tested at tilt 3.6 - same).

In addition, GCC 4.8 and 4.9 do not cause any errors on this code, which is what I want is also wrong.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -