lox-d/src/clox/util.d
2025-06-05 20:12:29 +00:00

20 lines
383 B
D

module clox.util;
import std.stdio;
import std.traits : isUnsigned;
import std.container.array;
import std.functional : unaryFun;
T validateAssert(alias pred = "!!a", T)(T v, lazy string msg = null) nothrow {
try{
string m = msg;
static if(is(typeof(pred) == string))
m = msg ? msg : pred;
assert(v.unaryFun!pred, m);
return v;
} catch(Exception){
assert(0);
}
}