C++ Logo

std-proposals

Advanced search

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

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Fri, 6 May 2022 11:03:04 +0100
On Fri, 6 May 2022 at 09:38, organicoman <organicoman_at_[hidden]> wrote:

> The resource leaks. But that's fully defined behavior; you can accomplish
> the same by an unpaired resource acquisition: int main() { new int; } is a
> perfectly valid program.
>
> Yes, in the above example, terminating the program will take care of
> freeing the resource.
> My question is, what strong guarantee the "Relocation" concept will
> provide? In other words, what should I watch for? Since the closing curly
> baces will not mean "calling destructor" necessarily.
>

The resource will continue to be managed, but by a different object; the
lvalue object materialized from the prvalue relocated from the original
owner lvalue. So it will be released when the new object's destructor is
called.

Received on 2022-05-06 10:03:16