Jonathan M Davis:
Another alternative would be to use a function like
std.algorithm.equal except
that it tested that one of the arguments was equal to the first
one rather than
just testing one argument against it. Something like
const Vertex opBinary(string op)(const ref Vertex vertex)
if (isOneOf(op, "+", "-"))
{...}
Off the top of my head, I'm not aware of a function like that
in the standard
library, but I may just not being think of it, and it probably
wouldn't be all
that hard to write, at least if efficiency wasn't a major
concern.
It's named std.algorithm.canFind:
if (["+", "-"].canFind(op))
Bye,
bearophile