- 从语言的层次:
容器Container是个class template;
算法Algorithm是个function template;
迭代器Iterator是个class template;
仿函数Function是个class template;
适配器Adapter是个class template;
分配器Allocator是个clsaa template;
Algorithm看不见Containers,对其一无所知;所以,它所需要的一些信息都必须从Iterators取得,而Iterators(由Containers供应)必须能够回答Algorithm的所有提问,才能搭配该Algorithm的所有操作。
//STL库中算法的形式
template<typename Iterator>
Algorithm(Iterator itr1,Iterator itr2)
{
}
//或
template<typename Iterator,template Cmp>
Algorithm(Iterator itr1,Iterator itr2,Cmp comp)
{
}
- 迭代器的分类
各种容器的iterators的iterator_category有:
//五种iterator category
struct input_iterator_tag{};
struct output_iterator_tag{};