|
Boost : |
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2019-06-03 10:59:34
> On 31. May 2019, at 01:50, Robert Ramey via Boost <boost_at_[hidden]> wrote:
>
> On 5/30/19 4:17 PM, Gottlob Frege via Boost wrote:
>
>> 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.
>
> This rather illustrates my point. As it stands now we've got std::variant, boost::variant and boost::variant2. And while we're at it don't for get std::optional, boost::optional, boost::outcome, std::expected? and ...?
>
> I don't think there's an general expectation that any of these are going to interoperate - but they might by accident.
Peter followed the spec for std::variant, so boost::variant2 is a drop-in replacement for std::variant. I think one should not use boost::variant anymore in new projects anymore. So the choice is really between std::variant (you need a C++17 compiler) and boost::variant2 (a C++11 compiler is sufficient), which are interchangeable.
Hans
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk