This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

basic_string<>::operator[] const


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]