Perfect forwarding
Stefan Koch
uplink.coder at googlemail.com
Wed Jul 29 20:07:35 UTC 2020
On Sunday, 26 July 2020 at 01:29:21 UTC, Andrei Alexandrescu
wrote:
> This topic came about during beerconf (it was fun!): Write an
> idiomatic template `forward` that takes an alias `fun` and
> defines (generates) one overload for each overload of `fun`.
> Example:
>
> template forward(alias fun)
> {
> ...
> }
>
> Now for this function:
>
> void myfun(int, ref double, out string);
> int myfun(in string, inout double);
>
> the instantiation would be (stylized):
>
> template forward!myfun
> {
> void myfun(int a, ref double b, out string c)
> {
> return myfun(a, b, c);
> }
> int myfun(in string a, inout double b)
> {
> return myfun(a, b);
> }
> }
>
> So the challenge is implementing forward() to do this.
I would be interested an actual use-cases for this?
Where would you use, forward? Where would it be the most pleasant
solution, and others would be vastly inferior?
More information about the Digitalmars-d
mailing list