GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::tuple_cat(3) C++ Standard Libary std::tuple_cat(3)

std::tuple_cat - std::tuple_cat


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.


The behavior is undefined if any type in std::decay_t<Tuples>... is not a
specialization of std::tuple. However, an implementation may choose to support types
(such as std::array and std::pair) that follow the tuple-like protocol.


args - zero or more tuples to concatenate


A std::tuple object composed of all elements of all argument tuples constructed from
std::get<j>(std::forward<Ti>(arg)) for each individual element.

// 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);
}
};


template<typename... Args, std::enable_if_t<sizeof...(Args) == 0, int> = 0>
void print(const std::tuple<Args...>& t)
{
std::cout << "()\n";
}


template<typename... Args, std::enable_if_t<sizeof...(Args) != 0, int> = 0>
void print(const std::tuple<Args...>& t)
{
std::cout << "(";
TuplePrinter<decltype(t), sizeof...(Args)>::print(t);
std::cout << ")\n";
}
// end helper function


int main()
{
std::tuple<int, std::string, float> t1(10, "Test", 3.14);
int n = 7;
auto t2 = std::tuple_cat(t1, std::make_tuple("Foo", "bar"), t1, std::tie(n));
n = 42;
print(t2);
}


(10, Test, 3.14, Foo, bar, 10, Test, 3.14, 42)


make_tuple creates a tuple object of the type defined by the argument types
(C++11) (function template)
tie creates a tuple of lvalue references or unpacks a tuple into
(C++11) individual objects
(function template)
forward_as_tuple creates a tuple of forwarding references
(C++11) (function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.