tuple_cat()函式,通過該函式可以將多個tuple連線起來形成一個tuple(註:在VC11中只能連線兩個tuple並不是真正的多個tuple)。
#include <iostream>
#include <utility>
#include <string>
#include <tuple>
int main ()
{
std::tuple<float,std::string> mytuple (3.14,"pi");
std::pair<int,char> mypair (10,'a');
auto myauto = std::tuple_cat ( mytuple, mypair );
std::cout << "myauto contains: " << std::endl;
std::cout << std::get<0>(myauto) << std::endl;
std::cout << std::get<1>(myauto) << std::endl;
std::cout << std::get<2>(myauto) << std::endl;
std::cout << std::get<3>(myauto) << std::endl;
return 0;
}
運行結果:
myauto contains:
3.14
pi
10
a