This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
templates and storing pointers to member functions
- From: Michael Haupt <mhaupt at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 24 Jun 2009 17:35:45 +0200
- Subject: templates and storing pointers to member functions
Hi,
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).
My problem is that I am stuck defining the correct type for f. It
should be able to represent member functions of arbitrary classes,
with arbitrary parameter lists. So far, I have something along the
lines of
template<typename T, typename... A> class D {
public:
typedef void (T::*fp)(A...);
};
to define myself a function pointer type:
class MyClass {
public:
typedef D<MyClass>::fp fp;
typedef map<MySymbol*, fp> fmap;
static fmap dmap;
};
The "typedef D" line, however, instantiates the template, binding T to
MyClass and binding (?) A... to "naught".
My understanding of the problem is that what I really want is a
partial instantiation of the template that still leaves the A...
unbound, creating a more generic type.
Is that possible at all?
I have done some research (obviously not enough) and have come to a
vague idea about using std::tr1::mem_fn and bind, but is that correct?
I would really appreciate some advice.
Thanks in advance,
Michael