How to implement predicates for Filter!(Pred, Tuple)

Tobias Pankrath tobias at pankrath.net
Fri Nov 11 12:38:49 PST 2011


David Nadlinger wrote:

> To be more precise, Tobias, my PApply!() would allow you to define your
> predicate »unnested«, i.e. just as a template with two parameters and
> then do StaticFilter!(PApply(IsEqual, 5), …).
> 
> But yes, not being able to »chain« template instantiation is quite a
> limitation of the D grammar when it comes to »higher-order templates«
> (at least that's what I like to call them). In some situations, you have
> no other options than to define an Instantiate!() template, see e.g. the
> Gist I posted.
> 
> David

Awesome, thank you :) That should really make its way into phobos someday.
However I wouldn't prefix everything with static, although it seems, that is 
the way phobos is going to do this. Instead I would use uppercase names for 
templates to distinguish them from normal functions.



More information about the Digitalmars-d-learn mailing list