How to use structs for RAII?

Sean Eskapp eatingstaples at gmail.com
Sat Jan 22 15:54:25 PST 2011


== Quote from bearophile (bearophileHUGS at lycos.com)'s article
> 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

By explicit constructor, I assume you mean one with parameters? I guess that's
alright.


More information about the Digitalmars-d-learn mailing list