$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Gavin Lambert (boost_at_[hidden])
Date: 2019-06-27 23:09:08
On 28/06/2019 07:57, David Sankel wrote:
>> If a class uses PIMPL and does a move, isn't that just a pointer swap
>> which cannot throw? Or would that be implemented as another allocation
>> in the moved-from class? I can't imagine why.
>
> Move assignment is fine. Move construction is where allocation would need
> to happen so the "moved from" object stays in a valid state.
I'm not sure why. Both unique_ptr and shared_ptr (one of which is
usually used as the "guts" of pimpl, depending on whether you want it to
be reference-semantics-copyable or not) do not need to allocate on move
construction (and are noexcept) -- they just leave the moved-from object
empty.