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 vs std::vector::reserve


Jonathan Wakely wrote:

>The standard was written explicitly so that COW strings would be
>possible (some implementors have since objected that it's worded to make
>non-ref-counted strings too difficult!)
>
>The only requirement on std::string::operator= is that capacity() should
>return "a value at least as large as size()", which libstdc++'s
>implementation does.
>
I only want to add that, in a non-COW implementation (for instance, the
current default in v7-branch), it would be trivial to change that
behavior and I even considered that a couple of days ago. However, I'm
not sure there is agreement among the implementors about the ""best""
behavior (from a QoI point of view): AFAIK, some non-COW implementations
also don't retain the capacity of this (when >= the needed one, of course)

Paolo.


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