public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58495] New: member function template all  of class template yield 'expected primary-expression'
@ 2013-09-21 17:22 imzhuli at vip dot qq.com
  2013-09-21 17:27 ` [Bug c++/58495] " paolo.carlini at oracle dot com
  2013-09-21 17:27 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: imzhuli at vip dot qq.com @ 2013-09-21 17:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58495

            Bug ID: 58495
           Summary: member function template all  of class template yield
                    'expected primary-expression'
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: imzhuli at vip dot qq.com

Created attachment 30878
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30878&action=edit
test case.

pls refer to the attachment (or the following code)
line 27 will cause an error(expected primary-expression), but line 24 & line 33
created object of same class and is able to call the member function template. 
Further more, if the f() is deducable, the call is allowed.

// example define: 

template<typename T>void f(T t); 

// call: (instead of line 27)

xFromB.f(123) ; // ok.

// end of example


 1 #include <iostream>
  2 #include <string>
  3 
  4 using namespace std;
  5 
  6 
  7 template<typename A>
  8 struct X
  9 {
 10   template<typename T>
 11     void f()
 12     {
 13       cout << "F" << endl;
 14     }
 15 };
 16 
 17 template<template<typename A> class B>
 18 struct Y
 19 {
 20   B<int> xFromB;
 21 
 22   void g()
 23   {
 24     X<int> directX;
 25     directX.f<int>(); // ok  
 26 
 27     xFromB.f<int>();  // error: expected primary expresion
 28   }
 29 };
 30 
 31 int main(int,char **)
 32 {
 33   Y<X> y;
 34   y.xFromB.f<int>(); // ok
 35 
 36   return 0 ;
 37 }
 38 
 39 
 40


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/58495] member function template all  of class template yield 'expected primary-expression'
  2013-09-21 17:22 [Bug c++/58495] New: member function template all of class template yield 'expected primary-expression' imzhuli at vip dot qq.com
  2013-09-21 17:27 ` [Bug c++/58495] " paolo.carlini at oracle dot com
@ 2013-09-21 17:27 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2013-09-21 17:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58495

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
You need to say:

   xFromB.template f<int>();

See http://womble.decadent.org.uk/c++/template-faq.html#disambiguation


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/58495] member function template all  of class template yield 'expected primary-expression'
  2013-09-21 17:22 [Bug c++/58495] New: member function template all of class template yield 'expected primary-expression' imzhuli at vip dot qq.com
@ 2013-09-21 17:27 ` paolo.carlini at oracle dot com
  2013-09-21 17:27 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-09-21 17:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58495

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|imzhuli at vip dot qq.com          |
         Resolution|---                         |INVALID

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
You want:

   xFromB.template f<int>();


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-21 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-21 17:22 [Bug c++/58495] New: member function template all of class template yield 'expected primary-expression' imzhuli at vip dot qq.com
2013-09-21 17:27 ` [Bug c++/58495] " paolo.carlini at oracle dot com
2013-09-21 17:27 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).