digitalmars.D - Question about using class refs as AA keys
- Jarrett Billingsley (18/18) Dec 30 2004 Is it safe to do something like this?
- Walter (5/23) Dec 30 2004 the
- Jarrett Billingsley (1/2) Dec 30 2004 Sweet :)
Is it safe to do something like this? Class Node { protected: static Node[Node] nodes; public: this() { nodes[this]=this; } ~this() { delete nodes[this]; } } I don't know how the GC works, but is this safe? I'm just wondering if the class references will change, causing the key to become invalid when the GC is run. Or are the class refs doubly indirected, making it safe?
Dec 30 2004
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:cr19ka$q75$1 digitaldaemon.com...Is it safe to do something like this? Class Node { protected: static Node[Node] nodes; public: this() { nodes[this]=this; } ~this() { delete nodes[this]; } } I don't know how the GC works, but is this safe? I'm just wondering iftheclass references will change, causing the key to become invalid when theGCis run. Or are the class refs doubly indirected, making it safe?Yes, it's safe to do it!
Dec 30 2004