Member function forwarding

Andrey Zherikov andrey.zherikov at
Thu Feb 17 20:59:43 UTC 2022

I have a struct that has struct data member and I'd like to 
forward some (not all) functions from internal data member. Some 
thing like this:
struct A {
     void foo() const { writeln(""); }

struct B {
     A a;

     auto foo(ARGS...)(ARGS args) { return; }
     // alias foo =;

void main()
     B b;;   // In "alias" case: Error: `this` for `foo` needs 
to be type `A` not type `B`

Is there simpler way to achieve this?
I tried `alias foo =` but it doesn't work: "Error: `this` 
for `foo` needs to be type `A` not type `B`" - when function is 
called (``).

Another question: does `auto foo(ARGS...)(ARGS args) { return; }` correctly forward `ref`, `const` etc. arguments?

More information about the Digitalmars-d-learn mailing list