Perfect forwarding
Adam D. Ruppe
destructionator at gmail.com
Sun Jul 26 01:44:27 UTC 2020
On Sunday, 26 July 2020 at 01:29:21 UTC, Andrei Alexandrescu
wrote:
> So the challenge is implementing forward() to do this.
I know the trick to do this, but I won't post the answer yet
because I don't want to ruin it for others who want to try.
However I'm going to point out that my trick doesn't work if you
are trying to forward a template, since template params cannot be
introspected. As far as I know, there is no solution to that.
My impl also does a bonus: forwarding UDAs as well. That requires
very new dmd though because until very recently that would hit a
compiler bug! But it is possible.
Note: part of the challenge is making sure it works with
user-defined types too. Your first thought of an implementation
might not, so test that with a struct from an import when there's
a local struct with the same name....
More information about the Digitalmars-d
mailing list