2
目录
1 介绍 ...............................................................................................................................................3
1.1 动机....................................................................................................................................3
1.2 STL 历史 ............................................................................................................................3
1.3 STL 和 ANSI/ISO C++草案标准.......................................................................................3
1.4 内容安排............................................................................................................................3
2 C++基础 ........................................................................................................................................4
2.1 类........................................................................................................................................4
2.2 函数对象(Function Objects)..............................................................................................5
2.3 模板(Template)..................................................................................................................5
2.3.1 函数模板.................................................................................................................5
2.3.2 类模板.....................................................................................................................6
2.3.3 模板特化.................................................................................................................7
3 STL 概貌 .......................................................................................................................................7
3.1 STL 网上信息.....................................................................................................................8
3.2 STL 文档 ............................................................................................................................8
3.3 编译 STL 程序...................................................................................................................9
4 学习 STL ......................................................................................................................................9
4.1 容器(Container) .................................................................................................................9
4.1.1 向量(Vector)..........................................................................................................10
4.2 迭代器(Iterator) ...............................................................................................................12
4.2.1 输入和输出迭代器...............................................................................................12
4.2.2 向前迭代器...........................................................................................................13
4.2.3 双向迭代器...........................................................................................................14
4.2.4 任意存取迭代器...................................................................................................14
4.3 算法和函数对象..............................................................................................................15
4.3.1 如何创建基本算法...............................................................................................15
4.3.2 STL 算法................................................................................................................17
4.4 适应器(Adaptor)..............................................................................................................19
4.4.1 容器适应器...........................................................................................................19
4.4.2 迭代适应器...........................................................................................................20
4.4.3
函数适应器...........................................................................................................20
4.5 分配算符和内存处理......................................................................................................20
5 其余的 STL 部件 .......................................................................................................................21
5.1 各部件如何协同工作......................................................................................................21
5.2 向量(Vector).....................................................................................................................21
5.3 线性表(List).....................................................................................................................22
5.4 双向队列(Deque).............................................................................................................22
5.5 迭代标签(Iterator Tag) ....................................................................................................22
5.6 关联容器(Container) .......................................................................................................22
6 版权信息.....................................................................................................................................24
7 文献 ............................................................................................................................................24
8 后话 ............................................................................................................................................25