On Thu, Jun 27, 2019 at 2:11 AM Alexander Grund via Boost < boost@lists.boost.org> wrote:
Am 27.06.19 um 04:03 schrieb David Sankel via Boost:
On Wed, Apr 17, 2019 at 8:42 AM Andrzej Krzemienski via Boost < boost@lists.boost.org> wrote:
wt., 16 kwi 2019 o 23:57 Richard Hodges via Boost < boost@lists.boost.org> napisaĆ(a):
Are there real-world examples of well-designed classes who's move assignment operators throw?
I think if I saw that in a code review I'd be inclined to demand a different design choice.
Is there a good reason that variants should support such classes?
Some implementations of std::list throw from their move constructors and default constructors. I understand that the implementation is easier if even an empty list has a dummy node, which requires allocation.
Also classes that use the PIMPL idiom.
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.