似乎迭代器适配器reverse_iterator
双重定义了它的大多数嵌套类型。特别是,它公开继承std::iterator
暴露的iterator_category
、value_type
、difference_type
和。除了and ,这些都在类定义中再次显式定义。pointer
reference
iterator_category
value_type
typedef
24.5.1.1 类模板 reverse_iterator [reverse.iterator]
namespace std {
template <class Iterator>
class reverse_iterator : public
iterator<typename iterator_traits<Iterator>::iterator_category,
typename iterator_traits<Iterator>::value_type,
typename iterator_traits<Iterator>::difference_type,
typename iterator_traits<Iterator>::pointer,
typename iterator_traits<Iterator>::reference> {
public:
typedef Iterator iterator_type;
typedef typename iterator_traits<Iterator>::difference_type difference_type;
typedef typename iterator_traits<Iterator>::reference reference;
typedef typename iterator_traits<Iterator>::pointer pointer;
// ... rest of the class
};
问题:为什么重复定义?这仅仅是为了说明,还是有更多的意义?为什么不重新定义iterator_category
and value_type
?