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] | |
On Thu, May 01, 2003 at 10:38:35PM +0200, Paolo Carlini wrote: > However, I'm not sure the standard guarantees that > swap exchanges also the capacities: I rely on that > property of v3 basic_string implementation. Is your concern about specializations of string on user character types? Since string::swap is required to run in constant time, it can't copy N characters. That almost implies the storage has to be the same, and thus, implicitly, the capacity as well. However, it is possible to implement string so that it stores small strings differently from larger ones, and does swap differently, still meeting the constant-time constraint while copying. Hmm, string::reserve() is cheap when capacity is already >= its argument, right? Might as well call it after the swap, just to be sure. Nathan Myers ncm-nospam@cantrip.org
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |