C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: DestructorConstructor - a class destructor with parameter
From: Maciej Polanski (maciejpolanski75_at_[hidden])
Date: 2021-02-11 11:25:04


On 2021-02-11 12:06, Marcin Jaczewski via Std-Discussion wrote:
>
> My favorite is:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1029r3.pdf
> It make effecitve "destructive move" using AS-IF rule becasue moved
> out object dectructor is noop.
> In case of vector you can simply `memcpy` data and only deallocate old memory
> (same effect as value init all old memory and then calling destructor
> and deallocation).

Thanks, I didn't know this proposal!

But I do not think it allows me to freely "memcpy", as elison depends on
compiler optimization and I do not know result of it.

It seems that having "bitcopies" constructor does not guarantee empty
destructor, nor lack of side effects of destructing empty object. It had
to be found by compiler during optimization.

Correct me if I am wrong, but if I was a library programmer,  I wouldn't
be able to find if I am allowed to memcpy of given class or not. Solely
having "bitcopies" constructor is not enough.

Thanks,
Maciej


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups