Member function forwarding

Stanislav Blinov stanislav.blinov at gmail.com
Fri Feb 18 08:02:57 UTC 2022


On Thursday, 17 February 2022 at 21:17:02 UTC, Andrey Zherikov 
wrote:
> On Thursday, 17 February 2022 at 20:59:43 UTC, Andrey Zherikov 
> wrote:
>> Another question: does `auto foo(ARGS...)(ARGS args) { return 
>> a.foo(args); }` correctly forward `ref`, `const` etc. 
>> arguments?
>
> Actually the answer is `NO`. I have to do `auto 
> foo(ARGS...)(auto ref ARGS args) { return
> a.foo(args); }`.

This also doesn't forward correctly. It'll always try to copy all 
arguments. What would fowrard is

```
import core.lifetime : forward;

auto foo(Args...)(auto ref Args args) { return 
a.foo(forward!args); }
```




More information about the Digitalmars-d-learn mailing list