November 17, 2015
On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote:
>
> Ok, that's a strange implementation of opIndex(). Usually, a parameter-less opIndex() is supposed to return a slice into the full range, but yours returns a size_t, which of course can't be iterated over.
>
> The change that made this stop working is:
> https://github.com/D-Programming-Language/dmd/pull/4948
>
> This contains, among others a fix for issue 14625 "opIndex() doesn't work on foreach container iteration":
> https://issues.dlang.org/show_bug.cgi?id=14625
>
> This allows to iterate directly over containers, without needing to slice them first. I guess it's a bit too eager, because if the object is already iterable without slicing (as in your example), it could just do that. On the other hand, it's a corner case, and it might actually be preferable to slice always, if the iterable supports it...
>
> In any case, I'd suggest you fix your opIndex(), except if there's a really good reason it is as it is.

I see. Thanks for the explanation. What would be the easiest fix for this example?
November 17, 2015
On Tuesday, 17 November 2015 at 12:41:45 UTC, Chris wrote:
> On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote:
>> In any case, I'd suggest you fix your opIndex(), except if there's a really good reason it is as it is.
>
> I see. Thanks for the explanation. What would be the easiest fix for this example?

Do you actually need the opIndex()? If not, just remove it.
November 17, 2015
On Tuesday, 17 November 2015 at 13:49:58 UTC, Marc Schütz wrote:
> On Tuesday, 17 November 2015 at 12:41:45 UTC, Chris wrote:
>> On Tuesday, 17 November 2015 at 12:22:22 UTC, Marc Schütz wrote:
>>> In any case, I'd suggest you fix your opIndex(), except if there's a really good reason it is as it is.
>>
>> I see. Thanks for the explanation. What would be the easiest fix for this example?
>
> Do you actually need the opIndex()? If not, just remove it.

I suppose that would be the easiest solution. I think I doesn't really need to be as it is.
1 2
Next ›   Last »