C++ Logo

std-discussion

Advanced search

Re: erase and iterator invalidation

From: Yongwei Wu <wuyongwei_at_[hidden]>
Date: Tue, 12 Dec 2023 17:42:01 +0800
On Tue, 12 Dec 2023 at 17:32, Bo Persson via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> std::string allows the Short String Optimization (which vector doesn't),
> so the memory layout is not guaranteed to be fixed.

Even with SSO, it is unimaginable that an implementation would
suddenly move all existing characters after an erase operation. It can
only happen after an insert.

So I am inclined to think now the specification is not due to any
practical considerations....

Received on 2023-12-12 09:42:14