2017-06-05 18:08 GMT+02:00 Peter Dimov via Boost
Gottlob Frege wrote:
It just means I need to double buffer higher up. I really want my drawing
program to just fail (rollback) the transaction if it can't complete - that is what users really want.
That's true, I understand that, and I tried to communicate the need for variant to support the strong guarantee on assignment for this reason.
So it looks like there are three choices for variant: 1. valueless_by_exception 2. with never-empty guarantee 3. with strong guarantee If you implement variant2 with only never-empty guarantee, you will still leave a group of people unsatisfied with either std::variant or variant2. Maybe you should just go for the strong guarantee, given that you are potentially doing double buffering anyway?
Normally, if your type was, say, vector<>, you don't need all vectors to be double-buffered. You do
vector<> tmp( v ); process( tmp ); v.swap( tmp ); // commit transaction
at the places where you want the strong guarantee.
Interestingly, this is also the case for `optional`: swap may throw.
The problem with variant<> is that the above doesn't quite produce the strong guarantee when the types aren't nothrow move constructible. I also tried to provide a solution to this problem in the form of pilfering, because types can typically be pilfered even when they can't be nothrow-moved-from, but this didn't go anywhere.
Didn't go anywhere in LWG; but maybe this idea can be tested in Boost. Regards, &rzej;