1. 程式人生 > >c++ tuple的基本操作

c++ tuple的基本操作

	//create tuple
	std::tuple<int,int> tp = std::make_tuple(2,2);
	int a,b;
	//get the value of tp
	std::tie(a,b) = tp;
	std::cout<<a+b<<std::endl;
	a = 0;
	//only get one value of tp
	std::tie(a,std::ignore) = tp;
	std::cout<<a<<std::endl;

	//combine more tuple-->tuple_cat
	std::tuple_cat(tp,std::make_tuple<int,char>(1,'a'));