C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Defined STL containers moved-from state

From: Bo Persson <bo_at_[hidden]>
Date: Wed, 22 Jan 2025 19:45:12 +0100
On 2025-01-22 at 19:03, Gia Phan via Std-Proposals wrote:
> Ohhh, so it's basically UB for:
> - Anything that requires reading any member or content of the moved
> containers,

Only if there aren't any content. The problem is that you don't know
without checking first.

> - Modifications like append, push(_back) to it without resetting all of
> its member/content to a deterministic state (assigning new value,
> reconstructing)

append and push_back will work, but is pretty useless if you don't know
what is in there beforehand. push_back will get you "one more than the
unknown previous number". Hard to see where that will be useful, but it
is still defined.

>
> I'll keep these in mind. I was just confused because it's not mentioned
> anywhere. Thank you!
>

Well, it kind of is.

Received on 2025-01-22 18:45:15