27 Jun
2019
27 Jun
'19
11:09 p.m.
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.