3 ms·
I rarely use the "for" or "while" keywords. I use the algorithms instead. The containers have been designed with this is mind. If you don't use the algorithms
by shin_lao 15y ago
I rarely use the "for" or "while" keywords. I use the algorithms instead.
The containers have been designed with this is mind.
If you don't use the algorithms, indeed, the STL can be cumbersome to use.
- jamesaguilar 15y agoBut then you have to define the loop internal logic elsewhere because C++ has no lambda (yet, at least in most places where it's used in production).
- jamesaguilar 15y agoBut then you have to define the loop internal logic elsewhere because C++ has no lambda (yet, at least in most places where it's used in production). God help you if you have a lot of variables that need to be compared or referenced inside the loop.
- shin_lao 15y agoWithout lambdas you use functors.
- jamesaguilar 15y ago> then you have to define the loop internal logic elsewhere
- shin_lao 15y agoThe loop is performed by the algorithms. See std::for_each, std::transform, std::accumulate, std::partition, etc., etc.
- rayiner 15y agoThe algorithms are a PITA without lambdas, and are not easily composable or extensible to express more complex iteration. None of them can work with multiple containers, which makes writing even something as simple as a "zip" function using the algorithms an exercise in futility.