This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
basic_string<>::operator[] const
- To: Benjamin Kosnik <bkoz@cygnus.com>
- Subject: basic_string<>::operator[] const
- From: Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de>
- Date: Wed, 9 Jun 1999 12:44:10 +0200 (CEST)
- cc: libstdc++@sourceware.cygnus.com
- Reply-To: Ryszard Kabatek <kabatek@chemie.uni-halle.de>
Is it neccesary to check for __pos != size() ?
Why only for the const version?
Is this requierd by the standard?
BTW. If we check for !=, so we can check for < instead.
// Element access:
const_reference
operator[] (size_type __pos) const
{
if (__pos != this->size()) // Why not: if (__pos < this->size())
return _M_data()[__pos];
else
return _Rep::_S_terminal;
}
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