STL源码剖析1
来源:互联网 发布:风机选型软件制作 编辑:程序博客网 时间:2024/05/17 04:40
stl概论
stl以抽象概念为主题而非以实际类为主的结构,形成了一个严谨的接口标准。在此接口之下,任何组件都有最大的独立性,并以所谓迭代器胶合起来,或以所谓配接器互相配接,或以所谓仿函数动态选择某种策略。
C++允许我们自行定义型别,C++template允许我们将型别参数化,藉由两者结合并透过traits变成技法形成STL。
stl六大组件:containers,algorithms,iterators,functors,adapters,allocators。
template<class T, class Sequence = deque<T> >
class stack
{
// friend bool operator == <T> (const stack<T>&, const stack<T>&); // OK
// friend bool operator == <T> (const stack&, const stack&); // OK
friend bool operator == <> (const stack&, const stack&); // OK
friend bool operator < <> (const stack&, const stack&);
// friend bool operator == (const stack&, const stack&); // error
};
..... // 实现省略
这种奇特的语法是为了实现所谓的 bound friend templates,也就是所说 class template 的某个具体实现与friend function template的某个具现体有一对一的关系。
int main()
{
stack<int> x;
stack<int> y;
cout << (x == y) << endl; // OK
stack<char> y1;
cout << (x == y1) << endl; // error
}
- STL源码剖析(1)
- STL源码剖析1
- STL源码剖析笔记(1)
- STL源码剖析笔记1
- 《stl源码剖析》剖析
- STL源码剖析笔记(1)
- 我读STL源码剖析(1)
- 《STL源码剖析》阅读笔记1
- STL源码剖析(1):空间配置器
- stl 源码剖析 1-9-5
- STL源码剖析(2)
- STL源码剖析(3)
- STL源码剖析(4)
- STL源码剖析(5)
- STL源码剖析(一)
- STL源码剖析
- STL 源码剖析
- STL源码剖析 [笔记]
- 高通平台android kernel 开机logo显示和传统linux一样
- 包冲突 axis.jar 在tomcat中总返回null gnujaxp.jar axis
- CodeForce 60 DSavior
- MFC的CRECORDSET对数据库的操作 .
- 在centos (linux) 搭建 eclipse c++开发分环境
- STL源码剖析1
- ios画pdf圈圈~
- FlyWeight模式
- SCM介绍
- VS2005不能进入断点调试, 注册表问题
- 作为Web开发人员,我为什么喜欢Google Chrome浏览器
- 重复注册按钮事件导致事件处理异常
- zoj3509 Island Communication
- Framework/base下添加自定义模块的编译