We discussed at length in this book how to think in terms of functions, and how function chaining and composition helps to create designs that are modular and composable. Yet, we hit a problem—with our current approach, a lot of data needs to be copied from one collection to another.
Fortunately, Eric Niebler took it upon himself to work on a library that enables a solution available in purely functional programming languages—lazy evaluation. The library, called ranges, was then officially accepted into the C++ 20 standard. In this chapter, we will see how to take advantage of it.
The following topics will be covered in this chapter:
- Why and when lazy evaluation is useful
- Introduction to the ranges library
- How to use lazy evaluation using the ranges library