Perfect forwarding
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Jul 26 01:29:21 UTC 2020
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.
More information about the Digitalmars-d
mailing list