Tuples in C++ and their Applications
Daniel Duffy
Abstract
Daniel Duffy
Abstract
In a programming language, a tuple is a data object containing other objects as elements or members. These elements may be of different types. This chapter gives a mathematical introduction to the concept of a tuple (or n-tuple) which is an ordered set of n elements or components of heterogeneous type where n is a non-negative integer. It then describes the main language features of std::tuple and reviews the functionality in std::pair (which is a 2-tuple) and by giving examples of the new features in C++11. The chapter also gives a discussion on how to avoid possible run-time performance bottlenecks when using std::tuple in the wrong way. It then discusses two libraries that offer similar functionality to std::tuple: Boost Tuple; and Boost Fusion. Furthermore, the chapter investigates the consequences of using tuples as return types of, and as input arguments to, functions. Finally, it summarizes the advantages and applications of tuples.
A significance statement is not available in the OpenAlex record.
A contribution statement is not available in the OpenAlex record.
Method details are not available in the OpenAlex metadata.
Findings are not separately available in the OpenAlex metadata.
Limitations are not available in the OpenAlex metadata.
Application details are not available in the OpenAlex metadata.
In a programming language, a tuple is a data object containing other objects as elements or members. These elements may be of different types. This chapter gives a mathematical introduction to the concept of a tuple (or n-tuple) which is an ordered set of n elements or components of heterogeneous type where n is a non-negative integer. It then describes the main language features of std::tuple and reviews the functionality in std::pair (which is a 2-tuple) and by giving examples of the new features in C++11. The chapter also gives a discussion on how to avoid possible run-time performance bottlenecks when using std::tuple in the wrong way. It then discusses two libraries that offer similar functionality to std::tuple: Boost Tuple; and Boost Fusion. Furthermore, the chapter investigates the consequences of using tuples as return types of, and as input arguments to, functions. Finally, it summarizes the advantages and applications of tuples.
Key concepts: Tuple, Tuple space, Computer science, Object (grammar), Set (abstract data type), Integer (computer science), Theoretical computer science, Programming language