shared and nonshared dtor

Vlad Levenfeld via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 19 19:57:42 PDT 2014


I have a Resource struct that is supposed to free some memory 
when it gets destroyed. Unfortunately, I can't define a 
destructor. If I do, the compiler complains that it can't destroy 
the shared versions. If I define a shared destructor, the 
compiler complains that it can't disambiguate between ~this() and 
shared ~this().

Is there a way around this or a better way to accomplish what I'm 
trying to do? I just want a lightweight handle to a 
manually-allocated dynamic array that I can append to and stuff, 
and frees itself on destruction (so I can keep them in various 
containers and know that freeing will automatically happen when I 
remove it).


More information about the Digitalmars-d-learn mailing list