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<>::reserve - patch


 
> In reserve I added a check for _M_state too. Otherwise it would not have
> the expected behaviour if the string has enough storage reserved but
> it has reference copies.

Right, it would lazily clone, but the clone would not get the 
reserved storage.
 
> BTW. In reserve we not check the __res_arg vlaue for a length_error.
>      If max_size() is much less than npos we should.
>      But I do not know if the standard allows reserve to throw
>      a length_error. If not it means that max_size() must return a value
>      very close to npos.
 
It is common to have (max_size() < npos/4), as in wstring.
I agree that it should throw before trying to allocate 
too much storage, and that the check should be based on
character units rather than bytes, to avoid overflow
errors.

Nathan Myers
ncm@cantrip.org

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