function template

std::make_tuple

<tuple>
template<class... Types>
  tuple<VTypes...> make_tuple (Types&&... args);
Make tuple
Constructs an object of the appropriate tuple type to contain the elements specified in args.

The type of the returned object (tuple<VTypes...>) is deduced from Types: For each type in Types, its decay equivalent is used in VTypes (except reference_wrapper types, for which the corresponding reference type is used instead).

Parameters

args
List of elements that the tuple object will contain.

Return Value

A tuple object of the appropriate type to hold args.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// make_tuple example
#include <iostream>
#include <tuple>
#include <functional>

int main()
{
  auto first = std::make_tuple (10,'a');             // tuple < int, char >

  const int a = 0; int b[3];                         // decayed types:
  auto second = std::make_tuple (a,b);               // tuple < int, int* >

  auto third = std::make_tuple (std::ref(a),"abc");  // tuple < const int&, const char* >

  std::cout << "third contains: " << std::get<0>(third);
  std::cout << " and " << std::get<1>(third);
  std::cout << std::endl;

  return 0;
}


Output:
third contains: 0 and abc

See also