'" error? - C++ Moderated [RSS]" href="http://www.talkaboutprogramming.com/group/comp.lang.c++.moderated/index.rss" />
Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: "expected p...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 9520 of 9807
Post > Topic >>

Re: "expected primary-expression before '>'" error?

by acehreli@[EMAIL PROTECTED] Apr 19, 2008 at 01:39 AM

On Apr 18, 4:19 pm, john.wilkinso...@[EMAIL PROTECTED]
 wrote:
> The following code gives an "expected primary-expression before '>'"
> error when compiled with gcc, Dev-C++ version 4.9.9.2. There is no
> such error with MSVC 2005 or 2008. I would be grateful to know if it a
> gcc bug, or alternatively what is wrong with the code.

gcc conforms to the standard and VC++ is behaving smarter than what
the standard requires.

> template< typename G >
> struct Test
> {
>     template< typename T > T f() const;
>
> };
>
>  template< typename G, typename T >
>  void g()
>  {
>      Test< G > t;
>
>      t.f< T >();  // error re****ted for this line
>  }

Above, f depends on a template parameter. It can be a member variable,
an enum value, a member function, etc. of Test<G>. Unless told, the
compiler cannot know that f is a template itself.

So it parses the < character as "less than" and gets confused later
on.

You must tell the compiler that f is a template so that it parses < as
the opening bracket of a template parameter list. Sorry for the busy
syntax: :)

       t.template f< T >();

Ali

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 4 Posts in Topic:
"expected primary-expression before '>'" error?
john.wilkinson43@[EMAIL P  2008-04-18 17:19:51 
Re: "expected primary-expression before '>'" error?
Matthew Collett <m.col  2008-04-19 01:39:24 
Re: "expected primary-expression before '>'" error?
acehreli@[EMAIL PROTECTED  2008-04-19 01:39:17 
Re: "expected primary-expression before '>'" error?
Thomas Maeder <maeder@  2008-04-19 02:01:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 19 20:03:30 CDT 2008.