How to use structs for RAII?

bearophile bearophileHUGS at lycos.com
Sat Jan 22 15:09:29 PST 2011


Sean Eskapp:

> It was recommended to me to use structs for RAII instead of scope classes,
> since scope is being removed (?). However, since default-constructors for
> structs can't exist, how does one do this?

Inside the ~this() you may put code, to deallocate resources you have allocated in an explicit constructor (or in some creation method). Is this enough?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list