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

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 4 15:13:56 PDT 2014


On 09/04/2014 02:04 PM, monarch_dodra wrote:

 > 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.

Yeah, there is something fishy with these operators.

Please see my other post. It seems like opIndex() is necessary or at 
least more convenient.

Ali



More information about the Digitalmars-d-learn mailing list