User defined type and foreach

Tony tonytdominguez at aol.com
Thu Nov 16 13:35:13 UTC 2017


On Thursday, 16 November 2017 at 13:10:11 UTC, ag0aep6g wrote:
> On 11/16/2017 09:03 AM, Tony wrote:
>> However, when I use the class with foreach, the opindex gets 
>> called to create a dynamic array, rather than use the 
>> empty(),front(),popFront() routines. I would prefer it use the 
>> three methods, rather than create a dynamic array.
>
> https://issues.dlang.org/show_bug.cgi?id=14619

And also this one which was marked as a duplicate of yours

https://issues.dlang.org/show_bug.cgi?id=16374

"When lowering a foreach, the compiler gives priority to opSlice 
over front/popFront/empty, which is counter-intuitive (and also 
undocumented)."

  "opSlice" -> "opSlice or opIndex".



More information about the Digitalmars-d-learn mailing list