www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Marking a delegate as pure, nothrow, etc.

reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
Is it possible to mark a delegate as pure,  safe, nothrow, etc.?  And if so,
how?
Apr 13 2014
parent "Meta" <jared771 gmail.com> writes:
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
Apr 13 2014