Forwarding arguments through a std.algorithm.map

Nordlöw per.nordlow at gmail.com
Fri Mar 16 16:35:36 UTC 2018


On Saturday, 10 March 2018 at 21:31:41 UTC, ag0aep6g wrote:
> Not tested beyond `f(1, 2.3, "foo")`:
>
> auto forwardMap(alias fun, Ts ...)(Ts things)
> {
>     import std.meta: aliasSeqOf, staticMap;
>     import std.range: iota;
>     import std.typecons: Tuple;
>     alias NewType(size_t i) = typeof(fun(things[i]));
>     alias NewTypes = staticMap!(NewType,
>         aliasSeqOf!(iota(things.length)));
>     Tuple!NewTypes results;
>     static foreach (i, thing; things) results[i] = fun(thing);
>     return results;
> }

Thanks! I'll try to put together something...


More information about the Digitalmars-d-learn mailing list