要点:
1 是标准库中std::pair的扩展,只不过pair是一个2-tuple
2 tuple最多可以支持10个元素
3 tuple较结构体相比,更容易声明,定义和使用;
4 与std::make_pair相对应的有boost::make_tuple
5 访问tuple
boost::tuple<int,double,std::string> triple(42,3.14,"The amazing tuple!");
int i=boost::tuples::get<0>(triple);
double d=triple.get<1>();
std::string s=boost::get<2>(triple);
6 tuple支持数据流操作,使用起来很方便
7 tuple最后一个特性是作为类型的容器,具体参见<c++设计新思维>
总结,tuple可作为简单结构体的替代,很方便;