//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'));
c++ tuple的基本操作
最新推荐文章于 2025-03-11 09:17:18 发布