Another interesting hack: expand a static array into parameter arguments

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Apr 3 01:56:50 PDT 2014


On 4/2/14, Artur Skawina <art.08.09 at gmail.com> wrote:
>    template expand(alias A, alias M=Delay) {
>       mixin(q{alias expand = TypeTuple!(}
>              ~ iota(A.length).map!q{",M!(A,"[!a..$]~text(a)~")"}().join()
>              ~ q{);});
>    }

You can always use string mixins for these hacks. But they are
terrible to debug, and likely slower to compile. I can barely make out
what the above code does even though I deal with mixins and templates
every day.


More information about the Digitalmars-d mailing list