C++ Logo


Advanced search

Re: On "transparently replaceable" in std::vector operations

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 28 Apr 2021 09:40:29 +0100
On Wed, 28 Apr 2021 at 09:17, Giuseppe D'Angelo via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> Why isn't the totally equivalent operation on `std::vector` valid as well?
> Note: an answer such as "this simply wasn't considered when that wording
> to [basic.life] was adopted in C++20 (?), LEWG paper please" is
> perfectly OK to me. As well as "you're missing this-and-that subclause,
> that's why", "implementations are allowed to implement vector with a
> prepend optimization", or similar.

Consider a T that is (CopyInsertable,CopyAssignable, and) MoveInsertable
but not MoveAssignable. An implementation may choose to shuffle the
elements along by destruct-and-move rather than copy assign. Invalidating
everything after the insertion point gives greater implementation freedom.

Received on 2021-04-28 03:40:42