How to initialize static array member variable?

Trass3r un at known.com
Thu Sep 30 14:10:00 PDT 2010


> I also tried simply
>
> struct Vector(alias N,T)
> {
>      static immutable Vector X=Vector(1,0,0);
>
>      this(T x,T y,T z) {
>          data[0]=x;
>          data[1]=y;
>          data[2]=z;
>      }
>
>      T data[N];
> };

This sort of constructor shouldn't be necessary since an implicit one will  
be generated.

You could also try "alias data this;" to make the vector usable like an  
array.

Here's a basic D2 fixed-size vector implementation for you to study:  
http://sfml.svn.sourceforge.net/viewvc/sfml/branches/sfml2/DSFML/import/dsfml/system/vector.d?view=markup


More information about the Digitalmars-d-learn mailing list