O'Reilly logo

Advanced Metaprogramming in Classic C++ by Davide Di Gennaro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required