[Issue 3720] Taking address of member functions possible without an instance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 5 15:23:36 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=3720

Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com

--- Comment #12 from Steven Schveighoffer <schveiguy at yahoo.com> ---
Isn't this the type/pointer assigned to delegates?

e.g.:

S s;
auto dg = &s.fun;
assert(dg.funcptr == &S.fun);

So it could be useful if you are doing something funky with the function
pointer portion of a delegate. Like for instance, selecting at runtime which
function pointer to use.

My preference would be to embed in the type of the function pointer, the fact
that it takes a hidden context pointer. Then the compiler can disallow simply
calling it without stuffing it into a delegate.

--


More information about the Digitalmars-d-bugs mailing list