4 ms·
> Foreach loops are still out of the question though For real? What's the argument there? I've never seen anyone complain about range-for, so I'm curious what
by MauranKilom 5y ago
> Foreach loops are still out of the question though
For real? What's the argument there? I've never seen anyone complain about range-for, so I'm curious what the perceived problem there is...
- gambiting 5y agoWe use our own game engines which still use lots of custom containers which won't necessarily work with a for each loop. In the best case you will get a cryptic error message, worst case it will look like it's working but actually be very inefficient or crash(that's what happens when games programmers start overriding Count to mean something else depending on the usage basically). It's a self inflicted wound basically.
- CodesInChaos 5y agoDoesn't foreach expand to the same `for(it = collection.begin(); it != collection.end(); ++it)` loop you'd otherwise write manually? Or are iterator based loops also avoided in that codebase?
- duped 5y agoMy complaint is that it sucks to write your own iterators that can be used in a range-for loop, unlike rust where it is a single interface. You even have a standard library function that converts a closure into an iterator.