Pointers to non-static member functions!
Daniel Murphy
yebblies at nospamgmail.com
Wed Jun 8 01:00:53 PDT 2011
Currently, this compiles:
class A
{
void func() {}
}
void main()
{
auto p = &A.func;
}
In this case, typeof(p) is void function().
Calling one of these pointers, of course, can easily give you a segfault as
it completely ignores the this pointer.
I didn't even realize you could do this until I saw
http://d.puremagic.com/issues/show_bug.cgi?id=5986
I understand that it could be useful to have a way to get the address of a
non-static member function, but I doubt returning a malformed function
pointer is really useful.
Does anybody think changing &ClassType.nonStaticMember to return void* would
be a bad idea?
More information about the Digitalmars-d
mailing list