This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::string::reserve()


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]