opSlice() or opIndex() for the entire slice?

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 4 14:04:33 PDT 2014


On Thursday, 4 September 2014 at 19:12:27 UTC, Ali Çehreli wrote:
> The documentation says "To overload a[], simply define opIndex 
> with no parameters":
>
>   http://dlang.org/operatoroverloading.html#Slice
>
> And it works with some uses of a[]. However, opSlice() seems to 
> be needed to actually use the returned slice further.

This must be new, as I've read that page several times, and have 
never seen that before. Furthermore, I've done a *lot* pulls to 
improve ranges' slicing capabilities, and no reviewer has ever 
mentioned this before.


More information about the Digitalmars-d-learn mailing list