C++ Logo


Advanced search

Re: [std-proposals] Relocation in C++

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Sun, 22 May 2022 22:31:59 -0600
On Sun, 22 May 2022 at 22:18, Thiago Macieira <thiago_at_[hidden]> wrote:

> On Sunday, 22 May 2022 21:12:52 PDT Edward Catmur wrote:
> > > If the mechanism is opt-out per type, then libc++ will opt out
> > > std::unique_ptr in the standard Library headers
> >
> > Why would they opt-out?
> >
> > To preserve (function argument passing) ABI.
> That of course means the standard can't mandate that the operator be
> present
> or it must allow the observable behaviour of using move+destroy instead of
> relocating on the implementation's choice.

The latter. It's the duty of the class author to ensure that the two have
no observable difference in behavior, just as they have a duty to ensure
that copy elision (NRVO, etc) does not in practice change the observable
behavior of the program. Any class where there is a difference is either
being used for debugging, for teaching, or is pathological. For
std::unique_ptr there is no observable difference, unless the deleter is
pathological, which std::default_delete is not.

Received on 2022-05-23 04:32:11