Perfect forwarding
Adam D. Ruppe
destructionator at gmail.com
Sun Jul 26 12:59:10 UTC 2020
On Sunday, 26 July 2020 at 10:51:44 UTC, Mathias LANG wrote:
> How do you forward this:
> ```
> class Foo
> {
> void set (time_t value = time()) {}
> }
> ```
The same as the others wrt the default argument. The fact it is
in a class complicates things a little since `this` is not
propagated through... but if I remove it from there it still
works.
Here's my solution as a link so people can look at it (and prolly
destroy holes i missed lol) if you want but not click if you
still wanna play with the challenge.
http://arsdnet.net/dcode/forward.d
The 8 lines at top are the forward, then the rest are the test
conditions.
BTW I'd note that just doing a speculative forward is a bit
simpler than this - you can just do (Args...)(auto ref Args args)
- but the linked technique does it ahead-of-time, as if you wrote
it by hand, meaning reflection still works on the forwarded
definitions too.
More information about the Digitalmars-d
mailing list