Adding moving to basic_string

chris jefferson caj@cs.york.ac.uk
Tue May 17 12:18:00 GMT 2005


Jonathan Wakely wrote:

>On Tue, May 17, 2005 at 11:56:04AM +0100, chris jefferson wrote:
>
>  
>
>>My understanding is that the problems from a non-reference counted 
>>basic_string fall into 2 main groups:
>>
>>Statements like "string s = a + b + c + d;", secondly things like"Return 
>>s" involves copying s, and then immediatly destroying it.
>>    
>>
>
>Doesn't the first case involve several temporary copies even with
>our ref-counted impl?
>
>  
>
You are right, reference counting doesn't really buy you anything here :)

 > > ....

>Could this work even with the current ref-counted implementation?
>If the boolean flag is set then there's no need to call _M_leak() to
>make a new copy, just decrement the ref-count on the temporary.
>
>  
>
You are also right, this kind of stealing of internal representation 
would work on a ref-counted copy too.. so it looks like this whole thing 
is tackling a useful, but totally different problem.. woops :)

Chris



More information about the Libstdc++ mailing list