scope(exit) without exception handling?

Mehrdad wfunction at hotmail.com
Wed May 16 13:54:26 PDT 2012


On Wednesday, 16 May 2012 at 20:48:27 UTC, H. S. Teoh wrote:
> 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

Haha maybe, idk. I just wrote what I wrote so that I could use it 
like:

noThrow({
	// giant block of code
});


to execute it as nothrow.


More information about the Digitalmars-d mailing list