当前位置:   article > 正文

C++11的tuple用法笔记_c++ tuple的用法

c++ tuple的用法


#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;
}





声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/305976
推荐阅读
相关标签
  

闽ICP备14008679号