- tuple[meta header]
- std[meta namespace]
- function template[meta id-type]
- cpp11[meta cpp]
namespace std {
template <class... Types>
tuple<VTypes ...> make_tuple(Types&&...); // C++11
template <class... Types>
constexpr tuple<VTypes ...> make_tuple(Types&&...); // C++14
}
渡された可変個パラメータのコピーからtuple
型のオブジェクトを構築する。
パラメータパックの値からなるtuple
オブジェクトを返す。
- C++11 :
Types...
の各型T
において、std::decay
<T>::type
の結果型を使用し、- かつ型
T
がstd::reference_wrapper
型であった場合T&
型を使用する
- C++20 :
Types...
の各型T
において、std::unwrap_ref_decay_t
<T>
を適用した型を使用する
#include <tuple>
#include <string>
#include <functional>
int main()
{
// 渡した値からtupleを構築
std::tuple<int, char, const char*> t1 = std::make_tuple(1, 'a', "Hello");
// tupleのコンストラクタによってconst char*をstd::stringに型変換
std::tuple<int, char, std::string> t2 = std::make_tuple(1, 'a', "Hello");
int a = 1;
char b = 'b';
std::string c = "hello";
// 変数のコピーからtupleを構築
std::tuple<int, char, std::string> t3 = std::make_tuple(a, b, c);
// 変数の一部を参照と見なしてtupleを構築
std::tuple<int, char&, const std::string&> t4 = std::make_tuple(a, std::ref(b), std::cref(c));
}
- std::make_tuple[color ff0000]
- std::tuple[link tuple.md]
- std::ref[link /reference/functional/ref.md]
- std::cref[link /reference/functional/cref.md]
- C++11
- Clang: ?
- GCC: ?
- GCC, C++11 mode: 4.6.1
- ICC: ?
- Visual C++: 2008, 2010