7 Ranges

This chapter covers

  • The problems of passing iterator pairs to algorithms
  • What ranges are and how to use them
  • Creating chained range transformations using the pipe syntax
  • Understanding range views and actions
  • Writing succulent code without for loops

In chapter 2, you saw why you should avoid writing raw for loops and that you should instead rely on using generic algorithms provided to you by the STL. Although this approach has significant benefits, you’ve also seen its downsides. The algorithms in the standard library were not designed to be easily composed with each other. Instead, they’re mostly focused on providing a way to allow implementation of a more advanced version of an algorithm by applying one algorithm multiple times. ...

Get Functional Programming in C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.