Parameterized Structs
spir
denis.spir at gmail.com
Thu Mar 3 05:54:19 PST 2011
On 03/03/2011 05:56 AM, Peter Lundgren wrote:
> Where can I go to learn about parameterized structs? I can't seem to find any
> literature on the subject. In particular, what are you allowed to use as a
> parameter? I would like to define a struct like so:
>
> struct MyStruct(T, T[] a) {
> ...
> }
>
> but I receive the following error:
>
> Error: arithmetic/string type expected for value-parameter, not T[]
>
> Are arrays not allowed?
Aside the error, I find this a bit strange. Do you really mean that /both/ a
type T and an element of type T[] are /template/ parameters? Would you show
your case? I expect (but may be wrong, indeed) something like this:
struct MyStruct(T) {
T[] a;
...
}
or maybe:
struct MyStruct(T) {
static T[] a = [...];
...
}
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list