[OT] unbelievable: #ifdef _OTHER_LIB_H
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Wed Nov 26 20:02:26 PST 2014
On Thu, 27 Nov 2014 03:51:58 +0000
"Adam D. Ruppe via Digitalmars-d" <digitalmars-d at 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();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141127/bfb61be3/attachment.sig>
More information about the Digitalmars-d
mailing list