This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: basic_string<>::max_size - only 1MB?
- To: solutions@josuttis.de
- Subject: Re: basic_string<>::max_size - only 1MB?
- From: Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de>
- Date: Thu, 24 Jun 1999 16:18:21 +0200 (CEST)
- cc: Benjamin Kosnik <bkoz@cygnus.com>, libstdc++ <libstdc++@sourceware.cygnus.com>
- Reply-To: Ryszard Kabatek <kabatek@chemie.uni-halle.de>
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