On Saturday, 21 April 2018 at 17:15:47 UTC, Jonathan M Davis
wrote:
On Saturday, April 21, 2018 16:05:22 Dr.No via
Digitalmars-d-learn wrote:
import std.meta : Filter;
enum isNotReservedSymbol(string name) = name != "none" && name
!=
"lastToken";
enum string[] members = staticMembers!Token;
static foreach(member; Filter!(isNotReservedSymbol, members))
{{
This return the error:
Error: template instance `pred!(["none", "word", "n",
"digits",
"name", /* my whole array here */ ]) does not match template
declaration isNotReservedSymbol(string name)
how should have isNotReservedSymbol be defined?
std.meta.Filter operates on an AliasSeq, not a dynamic array.
If you have an array, then you can just use
std.algorithm.iteration.filter with a normal lambda.
- Jonathan M Davis
I've tried use normal filter - albeit i'm willing to do all that
at runtin, but I got f cannot be read at compile time.
static foreach(member; staticMembers!Token.filter!(f =>
isNotReservedSymbol!(member))