Getting a working example of opIndexAssign using opSlice ... have troubles ...
Tejas
notrealemail at gmail.com
Mon Aug 16 06:20:11 UTC 2021
On Monday, 16 August 2021 at 06:12:42 UTC, james.p.leblanc wrote:
> 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
Maybe just write `T[]` in code rather than making it happen via
the colon?
I also have similar troubles, removing the default value always
helped me.
Can you show the code where you're trying to apply this?
More information about the Digitalmars-d-learn
mailing list