This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
__normal_iterator conversion bug
- To: Benjamin Kosnik <bkoz@cygnus.com>
- Subject: __normal_iterator conversion bug
- From: Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de>
- Date: Wed, 9 Jun 1999 13:45:28 +0200 (CEST)
- cc: libstdc++@sourceware.cygnus.com
- Reply-To: Ryszard Kabatek <kabatek@chemie.uni-halle.de>
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