<vector>, const_reverse_iterator and rend()

Alexandre Oliva oliva@dcc.unicamp.br
Sat May 30 16:26:00 GMT 1998


Niall Smart <njs3@doc.ic.ac.uk> writes:

vector<int> y; // given

>         vector<int>::const_reverse_iterator i = y.rbegin();

Since y is not const with -DBREAKME, the non-const version of rbegin()
must be selected on overload resolution.

Unfortunately, the FDIS does not require vector<T>::reverse_iterator
to be convertible to vector<T>::const_reverse_iterator.  In fact, it
cannot be made convertible without breaking the standard, because it
explicitly states that vector<T>::const_reverse_iterator is
std::reverse_iterator<vector<T>::const_iterator> and
vector<T>::reverse_iterator is
std::reverse_iterator<vector<T>::iterator>, then it defines that
std::reverse_iterator has a template constructor that copies the
`current' data member from reverse_iterator<U>.  Since it requires
`current' to be protected on reverse_iterators.  Perhaps the standard
should be rephrased so that it stated that the template constructor
copies u.base() instead of u.current, since u.base() is ensured to
return u.current.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil




More information about the Gcc-bugs mailing list