Detecting exception unwinding
Ola Fosheim Grøstad via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Feb 7 01:27:48 PST 2016
On Saturday, 6 February 2016 at 22:51:45 UTC, cy wrote:
> auto e = somethingThatFails()
> scope(failure) cleanup(e);
>
> makes more sense to me, since it's blatantly obvious that the
> construction (and entering) process isn't covered by the
> cleanup routine.
Not sure what you mean by that. Destructors shall not be called
if constructors fail, constructors should clean up themselves.
"scope(failure)" is useful for C-like APIs, but not a good
replacement for RAII.
More information about the Digitalmars-d-learn
mailing list