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: Benjamin Kosnik <bkoz@cygnus.com>, libstdc++ <libstdc++@sourceware.cygnus.com>
- Subject: Re: basic_string<>::max_size - only 1MB?
- From: Nicolai Josuttis <nicolai.josuttis@braunschweig.netsurf.de>
- Date: Thu, 24 Jun 1999 12:07:21 +0200
- Organization: Solutions in Time
- References: <Pine.LNX.3.96.990622150030.4635A-100000@happy.cygnus.com>
- Reply-To: solutions@josuttis.de
Benjamin Kosnik wrote:
>
> For string the issue is even less well-defined, because
> string::npos and string::max_size() have different, yet intertwined,
> meanings. For instance, string ctors check for length error based on
> npos, not max_size. This leads to problems if max_size is < npos: you can have a ctor trying to create a string of
>
This is on the library issues list of the standard commitee already:
83. String::npos vs. string::max_size()
Section: 21 lib.strings Status: Open Submitter: Nico Josuttis Date: 29 Sep
98
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.
--
Nicolai M. Josuttis
Solutions in Time
http://www.josuttis.de/
mailto:solutions@josuttis.de