Chapter 43. Composite Iterator Adaptations

 

Show me your flow charts and conceal your tables and I shall continue to be mystified. Show me your tables and I usually won’t need your flow charts; they’ll be obvious.

 
 --Frederick P. Brooks
 

But if less is more, think how much more more would be!

 
 --Dr. Frasier Crane, Frasier

Introduction

Naturally, you will now be pondering whether, and how, iterator adaptations may be used in concert. Well, the good news is that they can. The even better news is that you don’t need to write a new iterator adaptor in order to combine them!

Transforming a Filtered Iterator

Let’s imagine that we have a set of integers (int) and that we want to filter out the odd ones and then transform the remaining elements to double

Get Extended STL, Volume 1: Collections and Iterators now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.