std::string::reserve()

Paolo Carlini pcarlini@suse.de
Wed Nov 24 10:17:00 GMT 2004


Benjamin Kosnik wrote:

>Hi Neil.
>
>>  http://gcc.gnu.org/ml/libstdc++/2004-02/msg00212.html
>>    
>>
>Can you make a bugzilla report about this? 
>  
>
Hi everyone and sorry for late replying: I was working on something else...

The issue is largely not present in the current sources as a by product 
of recent work, cleaning-up and improving _S_create: basically, now we 
don't use anymore subpagesize. Strictly speaking we can still carrying 
out unnecessary memcpy in situations involving shrink-to-fit (*) && 
larger strings, but, IMO, perhaps we can live with that in the current 
basic_string implementation. More specifically, I don't like the idea 
of, so to speak, anticipating in reserve the intentions of _M_clone , 
using at this upper level of abstraction a knowledge of _M_clone inner 
logic... Please, let me think about this issue a little more...

Thanks!
Paolo.

(*) The very idea of shrink-to-fit, as we discussed in the original 
exchange, is rather special for string: f.i., people coming from vector 
don't even try it, as a simple reserve(0), I mean... ;)



More information about the Libstdc++ mailing list