function template
<tuple>

std::tuple_cat

template <class... Tuples>
  tuple<CTypes...> tuple_cat (Tuples&&... tpls);
Concatenate tuples
Constructs an object of the appropriate tuple type to contain a concatenation of the elements of all the tuples in tpls, in the same order.

Each element in the returned tuple is copy/move constructed (as if passed with forward).

Parameters

tpls
Comma-separated list of tuple objects. These may be of different types.

Return Value

A tuple object of the appropriate type to hold args.

The type of the returned object (tuple<CTypes...>) is the tuple type that contains the ordered sequence of all the extended types in Tuples.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// tuple_cat example
#include <iostream>     // std::cout
#include <utility>      // std::pair
#include <string>       // std::string
#include <tuple>        // std::tuple, std::tuple_cat, std::get

int main ()
{

  std::tuple<float,std::string> mytuple (3.14,"pi");
  std::pair<int,char> mypair (10,'a');

  auto myauto = std::tuple_cat ( mytuple, std::tuple<int,char>(mypair) );

  std::cout << "myauto contains: " << '\n';
  std::cout << std::get<0>(myauto) << '\n';
  std::cout << std::get<1>(myauto) << '\n';
  std::cout << std::get<2>(myauto) << '\n';
  std::cout << std::get<3>(myauto) << '\n';

  return 0;
}


Output:
myauto contains:
3.14
pi
10
a

Data races

The elements of tpls are accessed, and if any is an rvalue and its type supports move semantics for the construction invoked by this function, it is modified.

Exception safety

If none of the individual constructions of elements of tuple can throw, the operation never throws exceptions (no-throw guarantee).
Otherwise, if any tpls objects is not an lvalue, and at least one of the types in the resulting tuple can be constructed with move semantics from it, the operation may leave any number of such objects in an invalid state in case of exception (no guarantees).
Otherwise, the function only implies copies and the function produces no side effects (strong guarantee).

See also