simple struct template
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Fri Mar 30 08:23:09 PDT 2007
Hendrik Renken wrote:
> 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);
change that to:
Vector!(T) result;
result.x = x;
result.y = y;
result.z = z;
return result;
Static member function don't _have_ a "this"
> }
>
> }
>
>
> but then the compiler complains:
>
> function Vector.Vector!(float).Vector.opCall expected to return a value
> of type Vector!(float)
Because you didn't actually return anything.
More information about the Digitalmars-d-learn
mailing list