On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote:
On 2014-08-24 10:03, Bienlein wrote:

I have omitted the code for the TestClass class to save space. Problem
is that the compiler outputs this:

Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call
non-@nogc function 'core.exception.onOutOfMemoryError'
Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' cannot call
non-@nogc function 'std.conv.emplace!(TestClass, ).emplace'
Error: @nogc function 'main.nogcDel!(TestClass).nogcDel' cannot call
non-@nogc function 'object.destroy!(TestClass).destroy'

Is there a way to get around this?

@nogc is a very new attribute. The runtime and standard library have not been properly annotated with this attribute yet.

As a workaround you could try copy implementation of these functions to you're own code and annotate them as appropriate.

Shouldn't emplace and destroy infer their attributes instead of strictly annotating them as nogc.

Reply via email to