Question about opSlice

Ilya Ivanov via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 17 12:30:33 PDT 2015


On Tuesday, 17 March 2015 at 17:36:22 UTC, Ali Çehreli wrote:
> 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

Old-style opSlice works in my test too, but new-style doesn't. 
Filed the bug https://issues.dlang.org/show_bug.cgi?id=14302


More information about the Digitalmars-d mailing list