simple struct template

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Fri Mar 30 10:38:19 PDT 2007


Frits van Bommel wrote:
> 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;

Also I think you can use just Vector instead if Vector!(T) in those
routines. At least it works that way. Those extra letters are sooo
expensive.


More information about the Digitalmars-d-learn mailing list