scope(exit) without exception handling?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed May 16 13:49:37 PDT 2012


On Wed, May 16, 2012 at 10:41:06PM +0200, Mehrdad wrote:
> Oh, and I just invented a most *lovely* cast:  :P
> 
> auto noThrow(T)(scope T function() t) nothrow
> { return (cast(T function() nothrow)t)(); }
> 
> auto noThrow(T)(scope T delegate() t) nothrow
> { return (cast(T delegate() nothrow)t)(); }

What about:

	auto noThrow(T,U...)(scope T function(U) t) nothrow {
		return (cast(T function(U) nothrow)t)();
	}

	auto noThrow(T,U...)(scope T delegate(U) t) nothrow {
		return (cast(T delegate(U) nothrow)t)();
	}

?

(I've no idea if this actually works, but it does allow you to wrap
almost _any_ function.)


T

-- 
Lawyer: (n.) An innocence-vending machine, the effectiveness of which
depends on how much money is inserted.


More information about the Digitalmars-d mailing list