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:

[EMAIL PROTECTED] % /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

Reply via email to