Example for multi level template composition

rassoc rassoc at posteo.de
Mon Oct 10 08:44:19 UTC 2022


On 10/10/22 08:30, Arun via Digitalmars-d-learn wrote:
> Stumbled upon this question on HN https://news.ycombinator.com/item?id=33142751#33147401
> 
>> Can I write template A and then apply it to itself to get template B and then apply that onto template C to get template D.
> 
> Does anyone have an example for this?

Aren't UFCS chained range calls just that?

range.map!foo.filter!bar.fold!baz;

These templates return new template ranges that transform themselves according to their inputs via Design by Introspection. For example, joiner of joiner of joiner would allow you to lazily flatten a multi dim array.


More information about the Digitalmars-d-learn mailing list