Chapter 21. Tuples
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
21.1 Duos
A duo is the assembly of two objects into a single type. This is similar to the std::pair class template in the standard ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access