[Bug c++/58495] New: member function template all of class template yield 'expected primary-expression'
imzhuli at vip dot qq.com
gcc-bugzilla@gcc.gnu.org
Sat Sep 21 17:22:00 GMT 2013
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
More information about the Gcc-bugs
mailing list