Hi,

I'm trying to use std.typecons.RefCounted on recursive structures to emulate garbage-collected classes, but it doesn't work, because the RefCounted implementation ends up creating a cycle in the structure hierarchy.

import std.typecons: RefCounted;

struct S
{
RefCounted!S s; // error: struct S no size yet for forward reference
}

Even worst when I try to mix this with templates:

alias Node(T) = RefCounted!(_Node!T);
struct _Node(T)
{
    Node!T parent; // error: recursive template expansion
}

Is there some way to bypass these limitations, and use refcounted structures like classes?

Thank you in advance.

Reply via email to