On Wednesday, 3 May 2023 at 11:38:46 UTC, Adam D Ruppe wrote:
On Tuesday, 2 May 2023 at 13:57:23 UTC, Steven Schveighoffer wrote:
Isn't that what `__traits(child)` is for?


Yes, `__traits(child, object, method_alias)(args)` is the way to do it.

This doesn’t work, but a slight modification does the trick:

--- a.d
#line 3 "a.d" // for run.dlang.io

struct S
    private void f() {}
alias Sf = S.f;

--- b.d
#line 12 "b.d" // for run.dlang.io

import a;

void main()
    S s;
__traits(child, s, Sf)(); // error: Error: struct `a.S` function `f` is not accessible
    (&__traits(child, s, Sf))(); // ok

Thanks for making me aware of `__traits(child)`.

Reply via email to