April 13, 2014
Is it possible to mark a delegate as pure, @safe, nothrow, etc.?  And if so, how?
April 13, 2014
On Sunday, 13 April 2014 at 17:58:27 UTC, Joseph Rushton Wakeling wrote:
> Is it possible to mark a delegate as pure, @safe, nothrow, etc.?  And if so, how?

If it's while creating a delegate literal, it's valid to mark it with @safe pure nothrow:

auto n = delegate int() @safe pure nothrow { return 1; };

If it's an already-existing delegate, you can use a cast:

auto m = 0;
auto del = delegate int() @system { throw new Exception("test"); return m; }
cast(int delegate() @safe pure nothrow)del //del is now @safe pure nothrow