Generic multiargument overload. Constructs a string using the print function.
Generic style
import mir.exception; try throw new MirException("Hi D", 2, "!"); catch(Exception e) assert(e.msg == "Hi D2!");
C++ style
import mir.exception; import mir.format; try throw new MirException(stringBuf() << "Hi D" << 2 << "!" << getData); catch(Exception e) assert(e.msg == "Hi D2!");
Low-level style
import mir.exception; import mir.format; stringBuf buf; try throw new MirException(buf.print( "Hi D", 2, "!").data); catch(Exception e) assert(e.msg == "Hi D2!");
@safe pure nothrow @nogc bool func(scope const(char)[] msg) { /// scope messages are copied try throw new MirException(msg); catch(Exception e) assert(e.msg == msg); /// immutable strings are not copied static immutable char[] gmsg = "global msg"; try throw new MirException(gmsg); catch(Exception e) assert(e.msg is gmsg); return __ctfe; } assert(func("runtime-time check") == 0); static assert(func("compile-time check") == 1);