Tuples and multiple return values in C++

  • Authors:
  • Jaakko Jarvi

  • Affiliations:
  • -

  • Venue:
  • Tuples and multiple return values in C++
  • Year:
  • 1999

Quantified Score

Hi-index 0.00

Visualization

Abstract

A generic tuple class, capable of storing an arbitrary number of elements each being of arbitrary type, is presented. The class offers a concise means to return multiple values from a function. Instead of using refrerence parameters to pass data out of functions, the function return type is an instantiation of the tuple template, grouping the values to be returned. The semantics of the tuple class is analogous to the pair template in the C++ standard library, thus the usage of tuples is convenient and intuitive. The implementation is described in details. Efficiency considerations are addressed. It is shown that with modern C++ compilers, there is no extra runtime overhead caused by using tuples. However, due to excessive template instantiatons, there is some effect on compilation times and memory usage during compilation. This effect is unlikely to be significant in real programs.