14 The Power Ranges – C++ Ranges; Date and time handling
This chapter covers
- Understand what ranges are and how they simplify and improve your code
- Exploring the concepts of pipelines, lazy evaluation, views, actions, and compositions
- Learning how to handle time using the chrono library
- Writing two computer games – A secret knock game and a slot machine game
In this chapter, we dive into some very powerful features of the most advanced form of C++. We kick things off with Ranges – a powerful new way to handle sequences of elements in different containers. You'll get to grips with exciting new terms like pipelines, views, lazy evaluation, actions, and more. You will understand why iterators and algorithms you learned about in Chapter 11, can get clunky, and how ranges revolutionize the way we iterate through collections, making our code simpler, more powerful, and just plain awesome.
We will also practice a bunch of examples using various range methods, including some fresh ones from the upcoming C++23 standard.