April 13, 2014 Marking a delegate as pure, nothrow, etc. | ||||
---|---|---|---|---|
| ||||
Is it possible to mark a delegate as pure, @safe, nothrow, etc.? And if so, how? |
April 13, 2014 Re: Marking a delegate as pure, nothrow, etc. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | 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
|
Copyright © 1999-2021 by the D Language Foundation