std::string::reserve()

Paolo Carlini pcarlini@suse.de
Wed Feb 11 22:50:00 GMT 2004


Paolo Carlini wrote:

> 2- Your change definitely makes sense but not calling _M_clone has
>   a not-completely-obvious effect: if the string is in the leaked
>   state it remains leaked, doesn't become sharable. Perhaps you
>   want to return early only if the string is already sharable?

... or, much better, simply remember to call _M_rep()->_M_set_sharable()
before returning, since reserve is supposed to invalidate pointers,
iterators, references anyway.

Paolo.



More information about the Libstdc++ mailing list