So this is more a stackoverflow question, but I feel like later searchers will be more likely to find it if I put it here.

if I have the following C++ code:

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);
    }

    static void DO_TASK()
    {
for(iterator i = foo_list.begin(); i < foo_list.end(); ++i)
        {
            (*i)->process();
        }

for(iterator i = foo_list.begin(); i < foo_list.end(); ++i)
        {
            (*i)->advance();
        }
    }

    virtual void process() = 0;
    virtual void advance() = 0;
}

How can I turn this into D? Is there a way to register that static list with the garbage collector so it doesn't look into it or anything?

Similarly, I feel like this would be an interface in D, but interfaces don't have constructors.

Reply via email to