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]

Re: basic_string<>::max_size - only 1MB?


On Thu, 24 Jun 1999, Nicolai Josuttis wrote:

>  Many string member functions throw if size is getting or exceeding npos.
> However, I wonder why they don't throw  if size is getting or exceeding
> max_size() instead of npos. May be
>  npos is known at compile time, while max_size() is known at runtime. However,
> what happens if size exceeds
>  max_size() but not npos, then ? It seems the standard lacks some
>  clarifications here. 
> 
> The proposed solution will probably be that in this case length_error gets
> thrown.

A logical value for npos is max_size() + 1.
Throwing in a case if a requierd length reaches or exceedes npos 
is then compatible with exceeding max_size().


BTW. Must the value of npos be size_type(-1) ?


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]