Date
2009-06-07.00:00:00
Message id
4543

Content

[ 2009-06-07 Howard adds: ]

Not meaning to be argumentative, but we have a decade of positive experience with the precedent of using the same name for the nested type as an external class representing an identical concept.

template<class Category, class T, class Distance = ptrdiff_t,
         class Pointer = T*, class Reference = T&>
struct iterator
{
    ...
};

template <BidirectionalIterator Iter>
class reverse_iterator
{
    ...
};

template <ValueType T, Allocator Alloc = allocator<T> >
    requires NothrowDestructible<T>
class list
{
public:
    typedef implementation-defined     iterator;
    ...
    typedef reverse_iterator<iterator> reverse_iterator;
    ...
};

I am aware of zero complaints regarding the use of iterator and reverse_iterator as nested types of the containers despite these names also having related meaning at namespace std scope.

Would we really be doing programmers a favor by renaming these nested types?

template <ValueType T, Allocator Alloc = allocator<T> >
    requires NothrowDestructible<T>
class list
{
public:
    typedef implementation-defined     iterator_type;
    ...
    typedef reverse_iterator<iterator> reverse_iterator_type;
    ...
};

I submit that such design contributes to needless verbosity which ends up reducing readability.