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?


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



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