Boost logo

Boost :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2019-05-30 23:17:51


On Tue, Apr 16, 2019 at 5:57 PM Richard Hodges via Boost
<boost_at_[hidden]> wrote:
>
> 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?
>
>

I'm going to say *most* classes have a throwing move operators.
Why? Because most classes have a custom copy constructor (because
people don't follow Rule of Zero like they should),
and thus most classes don't have *any* move operations.

So all the move operations are actually copy operations, and most of
those classes have a string or vector or whatever, and can throw on
copy.

Now, having said that, none of those classes actually throw in "real
life", because they only throw when memory is completely exhausted,
and have probably crashed already.
And on some systems that oversubscribe allocation, they don't throw at
all, they just crash.

Thus most move operators, whether they exist or not, don't really throw.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk