still confused about call by reference

Nathan Reed nathaniel.reed at gmail.com
Tue Oct 30 08:39:17 PDT 2007


Hoenir wrote:
> Derek Parnell schrieb:
>>     void opCall(T,U,V)(const T a, const U b, const V c)
>>     {
>>         x = cast(VT)a;
>>         y = cast(VT)b;
>>         z = cast(VT)c;
>>     }
> Thanks for your code. But is there a way to use code like the following:
> 
> vec3 opSub(vec3 v) {return vec3(x-v.x, y-v.y, z-v.z);}
> 
> It doesn't work with
>     vec3 opCall(U,V,W)(U a, V b, W c)
>     {
>         x = cast(T)a;
>         y = cast(T)b;
>         z = cast(T)c;
>         return *this;
>     }
> Tells me "type vec3!(real) is not an expression". (typedef double real)
> btw is it possible to return pointers?

I think the opCall needs to be declared static.

Thanks,
Nathan Reed


More information about the Digitalmars-d-learn mailing list