Essential Utilities
This chapter will introduce some essential classes from the C++ Utility library. Some of the metaprogramming techniques presented in the previous chapter will be used in order to work effectively with collections that contain elements of different types.
C++ containers are homogenous, meaning that they can only store elements of one single type. A std::vector<int>
stores a collection of integers and all objects stored in a std::list<Boat>
are of type Boat
. But sometimes, we need to keep track of a collection of elements of different types. I will refer to these collections as heterogenous collections. In a heterogeneous collection, the elements may have different types. The following figure shows an example of a homogenous collection of int
s and a heterogenous collection with elements of different types:
Figure 9.1: Homogenous and heterogenous collections
This chapter will cover a set of useful templates from the C++ Utility library...