Adding moving to basic_string

Paolo Carlini pcarlini@suse.de
Tue May 17 14:11:00 GMT 2005


Jonathan Wakely wrote:

>Move semantics could make it as efficient as this (but less ugly):
>
>a = ((b+c) += d);
>  
>
Humm, maybe now I see your *real* point ;)

We arrive in both cases to the above situation. Then things are
completely different. In the move-semantics + short-string optimization
case, we can often spare reallocating (b+c) (if there is sufficient
space available for d too) but then the final assignment is expensive.
In the reference-counted case b+c is technically shared, unfortunately,
and will be always reallocated *during* operator+=; then the final
assignment is cheap.

Paolo.



More information about the Libstdc++ mailing list