This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34264] New: Pointer to template method of a class A, does not work in template context for that class A
- From: "Erik dot Bouts at Shell dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Nov 2007 14:35:31 -0000
- Subject: [Bug c++/34264] New: Pointer to template method of a class A, does not work in template context for that class A
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I cannot compile the following simple program with the 3.2.3 g++ compiler.
#include <iostream>
#include <typeinfo>
using namespace std;
class A
{
public:
template <typename Type>
void method(void)
{
cout << "hello " << typeid(int).name() << endl;
}
};
template <class ClassA, typename Type>
void run(void)
{
typedef void (ClassA::*pMethod)(void);
pMethod p = &ClassA::method<Type>; // line 23, error message
A a;
(a.*p)();
}
int main(void)
{
run<A, int>();
return 0;
}
I get the error message:
s_vipm00@rijkes-n-d99578 % /usr/bin/g++ test.cpp
test.cpp: In function `void run()':
test.cpp:23: syntax error before `>' token
While on the SOLARIS, Windows or on Linux with the Portland Compiler this is no
problem to compile.
A pointer to a template method of a non-template class is no problem, since
this works for line 23:
pMethod p = &A::method<Type>; // line 23, error message
However templatizing this to ClassA is now suddenly a problem.
Your help will be most appreciated.
--
Summary: Pointer to template method of a class A, does not work
in template context for that class A
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Erik dot Bouts at Shell dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34264