On Thu, 27 Nov 2014 03:51:58 +0000 "Adam D. Ruppe via Digitalmars-d" <digitalmars-d@puremagic.com> wrote:
> BTW @nogc should have an escape hatch at least for assert(0, > allocate_a_message). The program is dying anyway, at least let me > conveniently format a descriptive error message. hey, but we can hack it! import std.traits; auto assumeNoGC(T) (T t) if (isFunctionPointer!T || isDelegate!T) { enum attrs = functionAttributes!T | FunctionAttribute.nogc; return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t; } void test () @nogc { assert(0, assumeNoGC(() { import std.format : format; return "%s".format("hi")~" there!"; })()); } void main () @nogc { test(); }
signature.asc
Description: PGP signature