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

Rob T rob at ucora.com
Thu Nov 8 16:19:47 PST 2012


Interestingly, this is a workaround that may be workable somehow. 
I've even been able to expand it so that the R.value type is 
determined by a temnplate.

struct node( P )
{
    P payload;
    node* pred;
    node* succ;
}

struct R( V )
{
    V value;
    alias node!R N;
    d_list!N Rlist;
}

struct d_list( N )
{
    N* head;
    N* tail;
    // even this works
    ref typeof(N.payload) getFirstValue(){
       return head.payload;
    }
}


--rt



More information about the Digitalmars-d-learn mailing list