digitalmars.D - Count of object references?
- Bottled Gin (8/8) Aug 25 2013 Hello All
- bearophile (8/13) Aug 25 2013 What you want is a container that keeps weak references
Hello All Given a class object, is there a way to find out the number of references to it. I have a situation where a container is holding an object and I would like to remove the object from the container if there is nobody else referencing it. Is it possible in D? Regards - Puneet
Aug 25 2013
Bottled Gin:Given a class object, is there a way to find out the number of references to it. I have a situation where a container is holding an object and I would like to remove the object from the container if there is nobody else referencing it. Is it possible in D?What you want is a container that keeps weak references (http://en.wikipedia.org/wiki/Weak_reference ). Currently (I think) there are no weak references in Phobos, but eventually it should be added. Probably somewhere there is some implementation. Bye, bearophile
Aug 25 2013