This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::string::reserve()
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: Neil Ferguson <nferguso at eso dot org>,LibStdC++ General List <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 11 Feb 2004 23:45:31 +0100
- Subject: Re: std::string::reserve()
- References: <402A9983.50600@eso.org> <402AAB6A.7070101@suse.de>
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.