On 2014-03-05 14:09:31 +0000, bearophile said:
Orvid King wrote:
couldn't the first be improved more by allowing something like:
T opOpAssign(string op : in("+", "-", "*", "/", "%", "^^", "&", "|",
"^", "<<", ">>", ">>>"), T)(T x)
The `in` there is my attempt to disambiguate between this type of
constraint and what I view as the most likely syntax for built-in
tuples.
While a static switch could be a little handy (I have desired it few
times, despite a static foreach is much more needed), there's no strong
need for that "in", You can use something like (untested):
T opOpAssign(string op, T)(T x)
if ("+ - * / % ^^ & | ^ << >> >>>".split.canFind(op))
Bye,
bearophile
Actually, there is static foreach if you are iterating over a tuple.
It's not always very obvious under what conditions the compiler
evaluates foreach though.
-S