CHAPTER 6

image

Algorithms

The implementation of an algorithm needs a generic I/O interface. You need to decide how and where functions get data and write results, and how and what intermediate results are retained. Iterators are an existing abstraction that helps solve this problem.

An iterator is a small data type that offers a sequential view over a dataset. Put simply, it’s a class that implements a subset of the operations that pointers can perform.

The importance of iterators is that they decouple functions from the actual data storage. An algorithm reads its input via a couple of iterators [begin...end) of unspecified type and often writes its ...

Get Advanced Metaprogramming in Classic C++ 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.