Trouble creating a formatted assert wrapper

Nick Treleaven invalid at example.net
Mon Sep 3 06:01:07 PDT 2012


On 03/09/2012 13:51, Nick Treleaven wrote:
> myAssertBody(condition, format("Assertion failed @ %s:%d: ", file, line,
> args));

Oops, that is unsafe, fixed:

void myAssert(string file = __FILE__, int line = __LINE__, Args...)(
     lazy bool condition, lazy string messageFormat, lazy Args args)
     if (args.length > 0)
{
     myAssertBody(condition,
         xformat("Assertion failed @ %s:%d: %s", file, line, 
xformat(messageFormat, args)));
}




More information about the Digitalmars-d mailing list