How to turn this C++ into D?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Nov 5 10:07:40 PST 2014
On 11/05/2014 09:17 AM, Patrick Jeeves wrote:
> class foo
> {
> static std::list<foo*> foo_list;
> typedef std::list<foo*>::iterator iterator;
> public:
> foo()
> {
> foo_list.push_back(this);
> }
> ~foo()
> {
> foo_list.remove(this);
> }
Going completely off-topic, I recommend against objects registering
themselves that way. That idiom has caused trouble in more than one
project for us.
In general, I think a constructor should not have side-effects unless
needed for the object's construction (e.g. allocating a resource for the
object should obviously fine).
Ali
More information about the Digitalmars-d-learn
mailing list