Maybe if we get that "any" function any time soon (pardon the pun), we
could simplify those constraints a little bit:

enum string[] binaryOps = ["+", "-", "*", "/", "%", "^^", "&", "|",
"^", "<<", ">>", ">>>", "~"];

void assertPred(string op, L, R, E)
               (L lhs, R rhs, E expected, lazy string msg = null,
string file = __FILE__, size_t line = __LINE__)
    if(any(op, binaryOps) &&
       __traits(compiles, mixin("lhs " ~ op ~ " rhs")) &&
       __traits(compiles, mixin("(lhs " ~ op ~ " rhs) == expected")) &&
       isPrintable!L &&
       isPrintable!R)
{
}

I don't recall what any will look like exactly, but something like
that could work I guess.

Reply via email to