simple struct template
Hendrik Renken
funsheep at gmx.net
Fri Mar 30 07:33:05 PDT 2007
> 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;
> }
ah, thanks for your help, now i understand the error message ^^.
Need to bother you once again.
how do i overload opCall, when i want to return the appropriate type, i
tried the obvious (at least for me):
struct Vector(T)
{
public: T x, y, z;
static Vector!(T) opCall(T x, T y, T z)
{
this.x, y, z = (x, y, z);
}
}
but then the compiler complains:
function Vector.Vector!(float).Vector.opCall expected to return a value
of type Vector!(float)
where i have defined the aliases.
regards,
hendrik
More information about the Digitalmars-d-learn
mailing list