Manipulating alias sequences

Ben Ogles benjaminogles at gmail.com
Mon Jul 15 15:28:27 UTC 2019


On Monday, 15 July 2019 at 14:50:20 UTC, Paul Backus wrote:
> Use a run-time Tuple instead of an AliasSeq:
>
> import std.typecons;
> auto args = tuple(0, 0);
> static foreach (idx, val; args) {
>     static if (user_defined_function_exists_for_arg!idx) {
>         args[idx] = user_defined_function();
>     } else {
>         args[idx] = gen_random_integral!(typeof(val));
>     }
> }
>
> Then use `fun(args.expand)` to pass the members of the tuple as 
> separate arguments to `fun`.

Amazing, this works great! Thanks.


More information about the Digitalmars-d-learn mailing list