std::tuple_cat
提供: cppreference.com
ヘッダ <tuple> で定義
|
||
template< class... Tuples > std::tuple<CTypes...> tuple_cat(Tuples&&... args); |
(C++11以上) (C++14以上ではconstexpr) |
|
args
内のすべてのタプルを連結したタプルを��築します。
std::decay_t<Tuples>... 内のいずれかの型が std::tuple の特殊化でない場合、動作は未定義です。 ただし、処理系はタプルライクな規約に従う型 (std::array や std::pair など) をサポートしても構いません。
目次 |
[編集] 引数
args | - | 連結する0個以上のタプル |
[編集] 戻り値
個々の要素に対して std::get<i>(std::forward<Ti>(arg)) から構築された、すべての引数タプルの全ての要素から構成される std::tuple オブジェクト。
[編集] 例
Run this code
#include <iostream> #include <tuple> #include <string> // 任意のサイズのタプルを表示するためのヘルパー関数 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<class... Args> void print(const std::tuple<Args...>& t) { std::cout << "("; TuplePrinter<decltype(t), sizeof...(Args)>::print(t); std::cout << ")\n"; } // ヘルパー関数おわり 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 = 10; print(t2); }
出力:
(10, Test, 3.14, Foo, bar, 10, Test, 3.14, 10)
[編集] 関連項目
引数の型によって定義される型の tuple オブジェクトを作成します (関数テンプレート) | |
左辺値参照の tuple を作成したり、タプルを個々のオブジェクトに分解したりします (関数テンプレート) | |
転送参照の tuple を作成します (関数テンプレート) |