Recursive data structure using template won't compile
Rob T
rob at ucora.com
Thu Nov 8 10:07:44 PST 2012
On Thursday, 8 November 2012 at 17:57:11 UTC, Philippe Sigaud
wrote:
> Rob, your original code:
>
> // d-linked list with templated payload
> struct d_list( T )
> {
> struct node
> {
> T payload;
> node* pred;
> node* succ;
> }
> node* head;
> node* tail;
> }
>
> compiles just fine for me (Linux 32bits, DMD 2.060).
>
> Even with some exercising, the template doesn't fail:
>
> void main()
> {
> auto list = d_list!(int)();
> }
>
>
Yes that part works fine, but that's only the d_list part. When I
try to use my supposedly re-usable d-list to define a recursive
struct, that's when it fails. Take another look at the original
post, you'll see what I mean.
--rt
More information about the Digitalmars-d-learn
mailing list