Recursive data structure using template won't compile
    Rob T 
    rob at ucora.com
       
    Wed Nov  7 22:39:27 PST 2012
    
    
  
I want to create a simple recursive data structure as follows:
struct R
{
    int value;
    d_list!R Rlist;
}
// d-linked list with templated payload
struct d_list( T )
{
    struct node
    {
       T payload;
       node* pred;
       node* succ;
    }
    node* head;
    node* tail;
}
The compiler complains about node having "forward references".
I was able to get something like this to work in C++, so I 
imagine I can also get it to work in D, but does anyone know how?
I also want to template the recursive structure itself to specify 
the value type, ie struct R(T){ T value; d_list!R Rlist; }, but I 
left that out to keep the example more simple.
I've been stuck on this problem all day, so any help is 
appreciated!
--rt
    
    
More information about the Digitalmars-d-learn
mailing list