try/catch idiom in std.datetime
Jonathan M Davis
jmdavisProg at gmx.com
Mon Nov 18 01:18:48 PST 2013
On Monday, November 18, 2013 09:59:44 Jacob Carlborg wrote:
> Just do something like this:
>
> void trusted_nothrow (alias block) ()
> {
> scope(failure) assert(0);
> block();
> }
>
> trusted_nothrow!({
> // code
> });
>
> Not as pretty. Yet another prefect example for AST macros :)
I don't see much gain over simply putting scope(failure) at the top. You just
avoid having to write the assertion yourself. I also expect that it wouldn't
work with return statements.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list