Throwing constructors and member destructors
Stanislav Blinov
stanislav.blinov at gmail.com
Tue Nov 20 13:20:08 UTC 2018
On Tuesday, 20 November 2018 at 13:01:40 UTC, Boris-Barboris
wrote:
> https://run.dlang.io/is/LdylJX
>
> Notice no "B destructor" line in stdout.
>
> Just got bitten by the assumption that my Buffer struct that
> transactionally aquires multiple external resources in
> constructor will rollback via member destructors that were
> successfully completed before the throw.
>
> Can I get a clarification about current semantics? Should I
> essentially never throw in constructors if I want to rely on
> scope-based RAII?
>
> And before we start a 10-page argument about the ideology of
> constructors, I would mostly just like to hear that this is
> documented somewhere, because I have certanly missed it.
https://dlang.org/changelog/2.083.0.html#reboot14246
More information about the Digitalmars-d-learn
mailing list