访问升压成员::元组 [英] accessing members of boost:: tuple
本文介绍了访问升压成员::元组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想实现像矢量&lt向量;提高::元组LT; INT,INT,INT> >日;我想接取元组的第一个元素来检查的条件。
可有人请告诉我该怎么办呢?我是新来提振。
提前致谢。
解决方案
的#include<升压/元组/ tuple.hpp>
#包括LT&;&iostream的GT;
#包括LT&;矢量>诠释的main()
{
的std ::矢量<提高::元组LT; INT,INT,INT> >伏;
v.push_back(升压:: make_tuple(1,2,3));
性病::法院LT&;<提高::获得℃的>(五[0])LT;<的std :: ENDL;
性病::法院LT&;<提高::获得< 1 GT;(五[0])LT;<的std :: ENDL;
性病::法院LT&;<升压::得到2>(五[0])&所述;&下;的std :: ENDL;
}
I am trying to implement a vector like vector< boost::tuple<int,int,int> >day; I want to acess tuple's first element to check a condition. can someone please tell me how to do it? I am new to boost. Thanks in advance.
解决方案
#include <boost/tuple/tuple.hpp>
#include <iostream>
#include <vector>
int main()
{
std::vector< boost::tuple<int, int, int> > v;
v.push_back(boost::make_tuple(1, 2, 3));
std::cout << boost::get<0>(v[0]) << std::endl;
std::cout << boost::get<1>(v[0]) << std::endl;
std::cout << boost::get<2>(v[0]) << std::endl;
}
这篇关于访问升压成员::元组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文