std::tuple_cat (3) Linux Manual Page
std::tuple_cat – std::tuple_cat
Synopsis
Defined in header <tuple>
template< class… Tuples > (since C++11)
std::tuple<CTypes…> tuple_cat(Tuples&&… args); (constexpr since C++14)
Constructs a tuple that is a concatenation of all tuples in args.
Parameters
args – zero or more tuples to concatenate
Return value
A std::tuple object composed of all elements of all argument tuples constructed from std::get<i>(std::forward<Ti>(arg)) for each individual element.
Example
// Run this code
#include <iostream>
#include <tuple>
#include <string>
// helper function to print a tuple of any size
template <class Tuple, std::size_t N>
struct TuplePrinter {
static void print(const Tuple &t)
{
TuplePrinter<Tuple, N - 1>::print(t);
std::cout << ", " << std::get<N - 1>(t);
}
};
template <class Tuple>
struct TuplePrinter<Tuple, 1> {
static void print(const Tuple &t)
{
std::cout << std::get<0>(t);
}
};
int main()
{
std::tuple<int, std::string, float> t1(10, "Test", 3.14);
int n = 7;
auto t2 = std::tuple_cat(t1, std::make_pair("Foo", "bar"), t1, std::tie(n));
n = 10;
print(t2);
}
Output:
See also
make_tuple (function template)
tie (function template)
forward_as_tuple (function template)
