Date: Mon, 2 May 2022 15:39:10 +0200
Hi,
On 02/05/2022 15:27, Edward Catmur via Std-Proposals wrote:
> Do you have examples of such classes?
>
>
> From my perspective, and this is predicated on relocation ending
> lifetime such that the destructor is not called on relocated instances,
> an important category of classes that can benefit from relocation is
> guard classes; those that perform important work maintaining invariants
> in their destructors. If instances of such classes are to be moved
> around - and sometimes this is unavoidable, even with C++17 temporary
> materialization - then they need to have a move constructor that tags
> the moved-from instance such that its destructor does not perform the
> work. Sometimes this can be done by setting a pointer member to nullptr,
> for example, but often a bool data member is necessary. All this work
> could be avoided if move were replaced with relocation, since the
> destructor would be called exactly once.
Sure, but this isn't the proposal at hand.
If I am not mistaken (please correct me), I think you're proposing a
*stronger* form of relocation, specifically one where the relocation
operation also ceases the lifetime, so the destructor isn't called
later. I'm talking about the proposal as it is, in which there's always
the need for such extra state, as the destructor is indeed invoked after
a reloc.
Thank you,
On 02/05/2022 15:27, Edward Catmur via Std-Proposals wrote:
> Do you have examples of such classes?
>
>
> From my perspective, and this is predicated on relocation ending
> lifetime such that the destructor is not called on relocated instances,
> an important category of classes that can benefit from relocation is
> guard classes; those that perform important work maintaining invariants
> in their destructors. If instances of such classes are to be moved
> around - and sometimes this is unavoidable, even with C++17 temporary
> materialization - then they need to have a move constructor that tags
> the moved-from instance such that its destructor does not perform the
> work. Sometimes this can be done by setting a pointer member to nullptr,
> for example, but often a bool data member is necessary. All this work
> could be avoided if move were replaced with relocation, since the
> destructor would be called exactly once.
Sure, but this isn't the proposal at hand.
If I am not mistaken (please correct me), I think you're proposing a
*stronger* form of relocation, specifically one where the relocation
operation also ceases the lifetime, so the destructor isn't called
later. I'm talking about the proposal as it is, in which there's always
the need for such extra state, as the destructor is indeed invoked after
a reloc.
Thank you,
-- Giuseppe D'Angelo
Received on 2022-05-02 13:39:14