function template
<tuple>

std::make_tuple

template<class... Types>
  tuple<VTypes...> make_tuple (Types&&... args);
Construct 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).

The function calls tuple's initialization constructor, forwarding args to it.

Parameters

args
List of elements that the constructed tuple shall 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

Data races

If any type in Types is an rvalue reference of a type supporting move semantics, its corresponding argument is modified.

Exception safety

The function provides the same level of guarantees to each object as provided by the corresponding element constructor.

See also