,
,
,
# pragma 一次 struct InputIteratorTag  {}; struct OutputIteratorTag  {}; struct ForwardIteratorTag : public InputIteratorTag {}; struct BidirectionalIteratorTag : public ForwardIteratorTag {}; struct RandomAccessIteratorTag : public BidirectionalIteratorTag {}; template, struct 会 { ,//typedef T ,,,,,,,,,,,,,,,,, ValueType; ,//typedef Distance ,,,,,,,,,, DifferenceType; ,//typedef T *,,,,,,,,,,,,,,,,,指针; ,//typedef T&,,,,,,,,,,,,,,,,,参考; ,typedef InputIteratorTag IteratorCategory;//迭代器的类型,(,包括上面那5个struct ) }; template struct IteratorTraits { ,//typedef typename 迭代器:ValueType ValueType; ,//typedef typename 迭代器:DifferenceType DifferenceType; ,//typedef typename 迭代器:Pointer 指针; ,//typedef typename 迭代器:参考文档引用; ,typedef typename  InputIterator struct IteratorTraits inline size_t 距离(InputIterator 首先,,InputIterator 最后) { 首先,return _Distance (,,,, IteratorTraits :: IteratorCategory(),),,,//这里第三个参数,并没有实际意义,不过正是它的存在,让_Distance实现重载 } template & lt; class InputIterator> inline size_t  _Distance (InputIterator 首先,InputIterator 最后,RandomAccessIteratorTag) { ,return last 作用;; } template & lt; class InputIterator> inline size_t  _Distance (InputIterator 首先,InputIterator 最后,InputIteratorTag) { ,size_t n =, 0; ,while (first !=,最后) ,{ + +才能; + + n才能; ,} ,return n; }
,