void myAssert(int line = __LINE__, string file = __FILE__, Args...)(lazy bool condition, lazy Args args) {

Won't that create "template code bloat" ? Ie everytime myAssert is used a new function is created.

There was if I remember some discussion regarding not passing __LINE__,__FILE__ in assert related functions because of that.

If backtrace worked properly we should be able to go up the stack and get line number information when the assert fails (no time penalty when assert doesn't fail).

Another option is to use a lazy tuple argument inside myAssert instead of variadic arguments, which allows to pass line and file AFTER, without template bloat.

A related question:
In C++ we can stringify arguments and use it to provide informative asserts without duplicating code specifying a string version of the condition: #define assert( isOK ) ( (isOK) ? (void)0 : (void)myAssert(#isOK,__LINE__,__PRETTY_FUNCTION__, __FILE__) )

Likewise for related quick debug functions:
#define DEBUG(val) myDEBUG(#val,val)

There seems to be no way of doing this currently (besides the ugly mixin(myAssertString("i==0")) which would parse the condition at CT).

Would that be possible to add?



Reply via email to