Getting a working example of opIndexAssign using opSlice ... have troubles ...

james.p.leblanc james.p.leblanc at gmail.com
Mon Aug 16 06:12:42 UTC 2021


On Monday, 16 August 2021 at 05:26:00 UTC, Tejas wrote:

> If you're finding the spec too hard, please try Ali's book. I'm 
> sharing the part on operator overloading below:
>
> http://ddili.org/ders/d.en/operator_overloading.html
>
> Please ping if you still have problems; I'll then write a full 
> program.

Hej Tejas!

Thanks for your message.  I have it working now.  Yes, Ali's book 
is
a tremendously good reference.  But, I had trouble digging out
the "magic sauce" from the pages to get this working.

I was able to find the sauce in a forum post by Adam Ruppe (his 
book is also
an excellent place for ideas and code).

With "opCast", my difficulty was the description of the type I 
wish to cast
to uses a colon ":".

Here is the line that allows it to function as desired:

**>>   T[] opCast(T : T[])(){... }**


Best Regards,
jpl




More information about the Digitalmars-d-learn mailing list