templates and storing pointers to member functions

Ian Lance Taylor iant@google.com
Wed Jun 24 21:55:00 GMT 2009


Michael Haupt <mhaupt@gmail.com> writes:

> what I would like to do is create a map<s, f> mapping some symbol type
> to functions (the latter are member functions of classes).

This is not actually a question about gcc.  It is a question about C++.
I recommend trying a C++ language group.

As far as I know what you are trying to do is impossible in C++.  It's
fundamentally a type-unsafe operation, since once an object is in the
map there is no way to know the type of function pointer.  So you can
only do it via a cast to void* or something similar.  But C++ is a
complicated language and I'm prepared to be surprised.

Ian



More information about the Gcc-help mailing list