assign value to *this like in c++?

Nicholas Wilson iamthewilsonator at hotmail.com
Thu Jun 20 12:26:40 UTC 2019


On Thursday, 20 June 2019 at 11:31:19 UTC, lyan wrote:
> On Thursday, 20 June 2019 at 11:28:53 UTC, lyan wrote:
>> Hi!
>>
>> I just started with D, read already a bit through the 
>> documentation but I'm currently stuck here at porting my 
>> vector3 class to D:
>>
>> inline void normalize() {
>>   *this /= length();
>> }
>>
>> How can I achieve that in D? Also: is there a way to overload 
>> /=, */ operators?
>>
>> Thanks for the help!
>
> The code is C++ btw. and I had a typo below, I meant /= and *= 
> operators.

If you're doing the porting to learn then what the others have 
said will get you there.

If you wan't to just get started with some 3d math there is 
https://github.com/d-gamedev-team/gfm (under math/gfm/math). Also 
useful to see what tricks they do to implement the features.

It you're new I can't recommend 
http://ddili.org/ders/d.en/index.html enough.

In future please post such questions to the learn forum.


More information about the Digitalmars-d mailing list