Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Nov 8 15:45:04 PST 2012


On 11/9/12, Nick Sabalausky <SeeWebsiteToContactMe at semitwist.com> wrote:
> FWIW, you should be able to work around the issue by making some of the
> pointers "void*". You'll lose some type safety and have to remember to
> cast things correctly, but it should at least make it compile (although
> I haven't tried it).

Perhaps another possible workaround is to use 'alias this'.

struct R
{
    struct Data
    {
        int value;
    }

    Data data;
    alias data this;

    d_list!Data Rlist;
}

May not work in all cases though..


More information about the Digitalmars-d-learn mailing list