pointer to template member function

Ian Lance Taylor iant@google.com
Fri Oct 13 20:10:00 GMT 2006


rodolfo@rodsoft.org writes:

> struct A
> {
>     void a() {}
> };
> 
> struct B : A
> {
>     template <class T> void b() {}
> };
> 
> typedef void (A::* ptr)();
> 
> int main()
> {
>     ptr x = &A::a, // 
> 	y = static_cast<ptr>(&B::b<int>); // g++ chokes here
> }
> // ---
> 
> G++ says that 
> 
> error: invalid static_cast from type 
> 	'<unresolved overloaded function type>' to type 'void (A::*)()'

I think this may be a bug.  I'm not enough of a C++ language laywer to
be sure.  It looks to me like g++ thinks the function is overloaded,
but I don't see how it could be.

You may want to report this at http://gcc.gnu.org/bugzilla/.  See
http://gcc.gnu.org/bugs.html.

Thanks.

Ian



More information about the Gcc-help mailing list