Parameterized Structs

Jonathan M Davis jmdavisProg at gmx.com
Wed Mar 2 21:23:51 PST 2011


On Wednesday 02 March 2011 20:56:41 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?

I've never tried anything but arithmetic types and strings for a template value 
parameter, so I don't know, but the error message would certainly imply that 
it's not allowed. Regardless, its value would have to be known at compile time.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list