anonymous template predicates
Vlad Levenfeld via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Apr 30 14:01:34 PDT 2015
I was wondering if there's a mechanism to make anonymous
templates, e.g.
given:
enum Policy {A, B}
alias List = TypeTuple!(...);
instead of this:
enum has_policy_A (T) = T.policy == Policy.A;
alias Result = Filter!(has_policy_A, List);
use something like this:
Filter!(T => T.policy == Policy.A, List);
I've tried templates that generate eponymous predicates from
mixed-in strings but these have a number of caveats that limit
their usability.
More information about the Digitalmars-d-learn
mailing list