Question about opSlice

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 17 10:36:20 PDT 2015


On 03/17/2015 09:29 AM, John Colvin wrote:
> On Tuesday, 17 March 2015 at 13:57:18 UTC, Ilya Ivanov wrote:
> [snip]
>
> I recently did a full Array2D with slicing and non-contiguous views etc
> and found that it was quite a nightmare getting all this stuff correct.
>
> I think your mistake is that opSlice needs to be a template to trigger
> the new-style slicing/indexing.
> E.g.
>
> opSlice(size_t dim)(size_t i, size_t j)

I have simple but working code for both methods at the following links:

 
http://ddili.org/ders/d.en/operator_overloading.html#ix_operator_overloading.opSlice

 
http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.multi-dimensional%20operator%20overloading

Ali



More information about the Digitalmars-d mailing list