boost tuple笔记(待续)
来源:互联网 发布:如何开通企业邮箱域名 编辑:程序博客网 时间:2024/05/17 01:03
tuple
//z 2011-06-18 22:35:34@is2120.CSDN 转载请注明出处
1. 概述
定义了一个有固定数目元素的容器,每个元素类型可以不同。类似pair,只是里面的元素更多。
可以将pair可以看作tuple的特例,tuple是pair的泛化。
tuple已被收入 c++ 0x TR1草案。
2. 类摘要
template <class T0,...,class T9>
class tuple
{
public:
tuple();
tuple(T0 to,...);
tuple(const tuple<...>&);
tuple& operator=(const tuple&);
tuple& operator=(const std::pair&);
template <int N> T get();
};
3. 细节
示例:
typedef tuple<int,string> my_tuple;
typedef tuple<int,my_tuple1> my_tuple2;
为方便创建tuple对象,tuple提供了make_tuple()函数。
访问元素
tuple中的 get<>()成员函数访问内部的值。
BOOST_AUTO(t,make_tuple(1,"char[]",100.0));
assert(t.get<0>() == 1);
assert(t.get<2>()==100.0);
cout << t.get<1>();
cout << ++t.get<0>();
------------------------------------------------------------------
//z 2011-06-18 22:35:34@is2120.CSDN 转载请注明出处
#include <cassert>
#include <string>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
using namespace std;
using namespace boost;
int main()
{
typedef tuple<int ,double ,string > my_tuple;
my_tuple t1 = make_tuple(1,100.0,string("abc"));
my_tuple t2 = make_tuple(1,200.0,string("def"));
assert(t1<t2);
my_tuple t3(t2);
assert(t2==t3);
return 0;
}
//z 2011-06-18 22:35:34@is2120.CSDN 转载请注明出处
- boost tuple笔记(待续)
- boost::tuple学习笔记
- boost::tuple学习笔记
- boost.tuple笔记
- 引领Boost(三)(Boost::tuple)
- 引领Boost(三)(Boost::tuple)
- boost tuple
- Boost::tuple
- Boost中的容器boost::tuple
- 超越boost: 1)tuple
- boost::tuple 用法详解
- boost:tuple解码
- Boost Tuple 库
- Boost C++: 数据结构---tuple
- boost之tuple
- 笔记3(list,tuple)
- boost::shared_ptr(待续)
- GDI+学习笔记(待续)
- 晴晴语录~~啧~~
- HELLO四(二):2812存储器映射及CMD
- oracle的视图
- 基于SSH框架的JAVA WEB程序员所需掌握技术
- windows+eclipse+cygwin+cdt+ndk环境搭建
- boost tuple笔记(待续)
- cygwin,cdt,eclipse搭建c,cpp环境
- struts1
- Mongo Wire Protocol(写MongoDB驱动必备)
- pl/sql之基本概念和块的结构
- HELLO五(一):2812中断系统概述
- HELLO六:2812的时钟系统
- oracle的约束和索引
- OpenCV背景去除的几种方法