Throughout this book we often use homogeneous containers and array-like types to illustrate the power of templates. Such homogeneous structures extend the concept of a C/C++ array and are pervasive in most applications. C++ (and C) also has a nonhomogeneous containment facility: the class (or struct). Tuples are class templates that similarly allow us to aggregate objects of differing types. We start with the duo—an entity analogous to the standard
std::pair template—but we also show how it can be nested to assemble an arbitrary number of members, thereby forming trios, quartets, and so forth.1
A duo is the assembly of two objects into a single type. This is similar to the
std::pair class template in the standard ...