__normal_iterator conversion bug
Ryszard Kabatek
rysio@rumcajs.chemie.uni-halle.de
Thu Dec 30 07:30:00 GMT 1999
const_cast removes the const attribute,
so the (just modified) copy constructor (see below)
allows a conversion from const_iterator to iterator.
This is a wrong direction...
// Allow iterator to const_iterator conversion
template<typename _Iter>
inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
: _M_current(const_cast<_Iterator>(__i.base())) { }
# include <string>
int main()
{
string::const_iterator I;
string::iterator J(I); // Does compile!
}
Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 (2466) Fax. +49 3461 46 2129
More information about the Libstdc++
mailing list