static map as a type function
Stefan Koch
uplink.coder at googlemail.com
Thu Sep 24 04:07:40 UTC 2020
On Thursday, 24 September 2020 at 03:51:55 UTC, Paul Backus wrote:
>
> template staticMap!(alias F, Args...) {
> static if (Args.length == 0)
> alias staticMap = AliasSeq!();
> else
> alias staticMap = AliasSeq!(F!(Args[0]), staticMap!(F,
> Args[1 .. $]));
> }
>
This code only works because tuples auto expand!
Without that piece of knowledge the template can't be understood.
And even then I find it a stretch to say this immediately looks
like a loop over a parameter tuple.
More information about the Digitalmars-d
mailing list