C++11的tuple用法笔记

来源:互联网 发布:知乎大神级别编 编辑:程序博客网 时间:2024/06/10 11:00


#include <iostream>#include <tuple>#include<vector>using std::cout ;using std::endl ;using std::tuple;using std::vector;using std::string;using std::get;using std::make_tuple ;auto handleCmd(){auto t1 = make_tuple(1, "a1", "b1", "c1");cout << get<0>(t1) << " ";cout << get<1>(t1) << " ";cout << get<2>(t1) << " ";cout << get<3>(t1) << " ";cout << endl;vector<tuple<int, string, string, string> > tv;tv.push_back(make_tuple(1, "a1", "b1", "c1"));tv.push_back(make_tuple(2, "a2", "b2", "c2"));vector< tuple<int, string, string ,string> >::iterator itr;for (itr=tv.begin(); itr!=tv.end(); itr++){cout << get<0>(*itr) << " ";cout << get<1>(*itr) << " ";cout << get<2>(*itr) << " ";cout << get<3>(*itr) << endl;}return t1;}





0 0
原创粉丝点击