Heterogeneous containers
Heterogenous containers, as opposed to regular homogenous containers, are containers containing different types; that is, in homogenous containers, such as std::vector, std::list, std::set, and so on, every element is of the same type. A heterogeneous container is a container where elements may have different types.
Static-sized heterogenous containers
C++ comes with two heterogeneous containers, std::pair and std::tuple. As std::pair is a subset of std::tuple with only two elements, we will only focus on std::tuple.
The std::tuple container
The std::tuple is a statically sized heterogeneous container that can be declared to be of any size. In contrast to std::vector, for example, its size cannot change at runtime; you cannot add or remove elements.
A tuple is constructed with its member types explicitly declared like this:
auto tuple0 = std::tuple<int, std::string, bool>{}; This will make the compiler generate a class which can roughly be viewed like this:
class...