1
#ifndef __GLIBCPP_INTERNAL_ITERATOR_BASE_TYPES_H
2
#define
__GLIBCPP_INTERNAL_ITERATOR_BASE_TYPES_H
3![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
#pragma GCC system_header
5![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
namespace
std
7![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
8![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
//定义了5种迭代器类型,但是都不含有任何成员,只用来标记迭代器类型。
10![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct input_iterator_tag
{};
11![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct output_iterator_tag
{};
12![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct forward_iterator_tag : public input_iterator_tag
{};
13![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct bidirectional_iterator_tag : public forward_iterator_tag
{};
14![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct random_access_iterator_tag : public bidirectional_iterator_tag
{};
15![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
//stl提供了一个iteraotr class,供每个新设计的迭代器继承它、。
18
//在这个迭代器里只是定义了iterator的五种常用型别,不含任何成员,
19
//所以继承它不会有任何额外负担,而且后三个参数已经有了默认值,故
20
//只需要提供前两个参数就可以了。
21
template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
22
typename _Pointer = _Tp*, typename _Reference = _Tp&>
23
struct iterator
24![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
25
typedef _Category iterator_category;
26
typedef _Tp value_type;
27
typedef _Distance difference_type;
28
typedef _Pointer pointer;
29
typedef _Reference reference;
30
};
31![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32
//针对含有non-trivial constructor,non-trivial destructor,non-trivial copy constructor,
33
//non-trivial assigment construstor的类型使用的traits版本。定义了5种常用型别
34
template<typename _Iterator>
35![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct iterator_traits
{
36
typedef typename _Iterator::iterator_category iterator_category;
37
typedef typename _Iterator::value_type value_type;
38
typedef typename _Iterator::difference_type difference_type;
39
typedef typename _Iterator::pointer pointer;
40
typedef typename _Iterator::reference reference;
41
};
42![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
43
//针对原生指针的traits偏特化版本
44
template<typename _Tp>
45![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct iterator_traits<_Tp*>
{
46
typedef random_access_iterator_tag iterator_category;
47
typedef _Tp value_type;
48
typedef ptrdiff_t difference_type;
49
typedef _Tp* pointer;
50
typedef _Tp& reference;
51
};
52
//针对原生指针之pointer-to-const版本的traits偏特化版本
53
template<typename _Tp>
54![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
struct iterator_traits<const _Tp*>
{
55
typedef random_access_iterator_tag iterator_category;
56
typedef _Tp value_type;
57
typedef ptrdiff_t difference_type;
58
typedef const _Tp* pointer;
59
typedef const _Tp& reference;
60
};
61![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
62![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63
//返回迭代器类型
64
template<typename _Iter>
65
inline typename iterator_traits<_Iter>::iterator_category
66
__iterator_category(const _Iter&)
67![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ return typename iterator_traits<_Iter>::iterator_category(); }
68![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69
}
//
namespace std
70
71
#endif
/* __GLIBCPP_INTERNAL_ITERATOR_BASE_TYPES_H */
72
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
8
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
11
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
12
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
13
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
14
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
15
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
25
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
28
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
30
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
31
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
32
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
34
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
36
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
38
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
39
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
40
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
41
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
42
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
43
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
44
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
45
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
46
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
48
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
49
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
50
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
52
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
54
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
55
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
56
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
58
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
59
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
60
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
61
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
62
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
64
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
65
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
66
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
68
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69
![ExpandedBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
70
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
71
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
72
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)