3 ms·
Range-based for loops are far more idiomatic for modern C++: https://stackoverflow.com/a/15089298/1111557 https://stackoverflow.com/a/15089298/1111557
by inetknght 8y ago
Range-based for loops are far more idiomatic for modern C++: https://stackoverflow.com/a/15089298/1111557 https://stackoverflow.com/a/15089298/1111557
- saagarjha 8y agoThey're also not in the standard library. Not everyone can justify integrating Boost into their applications :(
- Y_Y 8y agoYou can certainly do this with just the standard library and no boost, for example using iota from <numeric>. https://en.cppreference.com/w/cpp/algorithm/iota https://en.cppreference.com/w/cpp/algorithm/iota
- saagarjha 8y agoThat’s not a generator, though. You need to allocate an extra container for this to fill, which is inconvenient.
- bonzini 8y agoAnd underneath they compile to an int for loop and a pointer dereference, both of which can be undefined behavior.