Is remove safe using foreach

Steven Schveighoffer schveiguy at gmail.com
Tue Dec 13 01:54:44 UTC 2022


On 12/12/22 8:45 PM, Steven Schveighoffer wrote:

> for(auto r = aa.byKey, auto k = r.front; !r.empty; r.popFront)

err... forgot the continual front assignment
I think it's more like:

for(auto r = aa.byKey; !r.empty; r.popFront) {
    auto k = r.front;
    // foreach body
}

-Steve


More information about the Digitalmars-d-learn mailing list