Re: [Vala] List with composed type



Am Sonntag, den 25.10.2009, 22:30 +0100 schrieb Johan:
Hi,

I want to construct a List (can be any kind of linked list) where each 
element is a struct (or it could be an object):

 struct StructType{
       string s1;
       string s2;
       string s3;
   }

 var list = new List<StructType> ();

output from valac:
'StructType' is not a supported generic type argument, use `?' to box 
value types

Seems that List does only accept simple types. Is there any simple way 
to implement it without rewriting the whole code of a linked list?
thanks for any help!
You could use a normal class (GType) or an object (GObject) instead,
i.e. something allocated on the heap. Structs are allocated on the
stack and thus do not work for things like generics. If a struct is
really needed, appending a ? after the type name works too.

Regards,
Julian




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]