simple struct template

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Fri Mar 30 06:37:37 PDT 2007


Hendrik Renken wrote:
>> alias Vector!(float) Vectorf;
>> alias Vector!(double) Vectord;
>>
>> Should work; if not, what error message is the compiler giving you?
>>
> dmd on linux32, gdc 0.23 on mac os:
> "template instance forward reference to template declaration Vector(T)"

Put your aliases after the struct definition:

struct Vector(T)
{
   T x;
   T y;
   T z;
}

alias Vector!(float) Vectorf;

void main(char[][] args)
{
   Vectorf v;
   v.x = 0.2f;
}


More information about the Digitalmars-d-learn mailing list