Gesendet: Mittwoch, 22. Mai 2024 um 08:45 Uhr
Von: "Ion Gaztañaga via Boost"
A) "clear" in vectors does not reduce the capacity, I think that would be surprising because many times a user does not expect new allocations after clear() if the previous capacity was big enough.
OK
B) Moving to internal storage when move assigning could make the operation throwing, when moving the dynamic buffer can be faster and nothrow. LLVM and Folly take the dynamic buffer of the source vector if available:
This is true when you move from a dynamic buffer. If you move from the internal buffer, however, you must move the individual elements anyway.
C) Swap is similar to a double move assignment.
The interesting situation is when one vector uses a dynamic buffer and the other one the internal buffer. Currently swap allocates also a dynamic buffer for the vector with the internal buffer. Helmut