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("A.foo"); }
}
struct B {
A a;
auto foo(ARGS...)(ARGS args) { return a.foo(args); }
// alias foo = a.foo;
}
void main()
{
B b;
b.foo(); // 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 = a.foo
but it doesn't work: "Error: this
for foo
needs to be type A
not type B
" - when function is called (b.foo()
).
Another question: does auto foo(ARGS...)(ARGS args) { return a.foo(args); }
correctly forward ref
, const
etc. arguments?