Workaround for RefCounted with classes would work?

Bienlein via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 19 12:39:05 PDT 2016


Hello,

RefCounted so far works well with structs, but not with classes 
(see http://wiki.dlang.org/DIP74). I have now set up a little 
kludge where a struct takes a class as a template parameter. The 
struct with the containing object, which is of the type of the 
struct's template type, is handed over to the RefCounted 
instance. When RefCounted calls the destructor of the contained 
struct, the destructor of the object contained by the struct is 
also called.

I have tried this out and it works fine. It seems to be good 
enough for my purposes. Question is whether there is some hidden 
problem with this approach. Anything I need to be aware of? I'm 
not proficient with D. So I thought it's better to ask ;-).

Regards, Bienlein


More information about the Digitalmars-d mailing list