Andrei Alexandrescu wrote:
Don wrote:
Not necessarily. Andrei can just add:

static if(__traits(compiles, mixin(comp) )) {
  mixin(comp);
} else {
   // static assert is a bit broken,
   // better to do it this way to provide a backtrace.
   pragma(msg, "Bad predicate: " ~ comp);
   deliberate_error_message; // t
}

into std.functional. Which will generate a very controlled error message.
(Doesn't work if the predicate contains mismatched parentheses, but that's fixable).

I tried the above and didn't quite work. The deliberate_error_message would trigger an error even for valid expressions. What I have now is this:

Use a string mixin for deliberate_error_message.

Reply via email to