I want to be able to filter a range based on a variable known at runtime. Something like this:

[code]
int id = getFilterID();

auto filteredRange = filter!(a => a.id == id)(rangeToBeFiltered);

[/code]

This doesn't seem to be possible, however as .filter only takes unary predicates. I tried:

[code]

filterString = "a.id == " ~ to!string(id);
filter!filterString(rangeToBeFiltered);

[/code]

But that also doesn't work. Is there another range algorithm that should be used in this case? Do I roll my own?

Reply via email to