Given an object, how to call an alias to a member function on it?
ag0aep6g
anonymous at example.com
Wed May 3 11:26:00 UTC 2023
On 03.05.23 13:13, Nick Treleaven wrote:
> On Tuesday, 2 May 2023 at 13:06:41 UTC, ag0aep6g wrote:
>> void fun(alias method)(C c)
>> {
>> void delegate() dg;
>> dg.funcptr = &method;
>> dg.ptr = cast(void*) c;
>> dg();
>> }
>
> This also works:
>
> void fun(alias method)(C c)
> {
> void delegate() dg = &c.method;
> dg();
> }
>
No, it doesn't. You're not using the alias. You're just accessing
`c.method` directly. If the actual method weren't called "method", you'd
get an error.
More information about the Digitalmars-d-learn
mailing list