Extend the call site default argument expansion mechanism?
jmh530
john.michael.hall at gmail.com
Tue May 15 13:59:37 UTC 2018
On Tuesday, 15 May 2018 at 13:16:21 UTC, Steven Schveighoffer
wrote:
> [snip]
>
> Hm... neat idea. Somehow, opDispatch can probably be used to
> make this work even more generically (untested):
>
> struct WithAlloc(alias alloc)
> {
> auto opDispatch(string s, Args...)(auto ref Args args) if
> (__traits(compiles, mixin(s ~ "(args, alloc)")))
> {
> mixin("return " ~ s ~ "(args, alloc);");
> }
> }
>
> -Steve
Example:
https://run.dlang.io/is/RV2xIH
More information about the Digitalmars-d
mailing list