std.unittests [updated] for review
Jonathan M Davis
jmdavisProg at gmx.com
Mon Jan 24 07:55:27 PST 2011
On Monday 24 January 2011 07:48:25 Andrej Mitrovic wrote:
> 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.
Assuming that it worked with CTFE, of course (surprisingly little in
std.algorithm works in CTFE from what I've seen). Ultimately, I don' think that
it matters all that much, since you need a list of the acceptable operators
somewhere regardless, but using any _would_ be a bit cleaner.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list