On 4/04/2019 13:26, Emil Dotchevski wrote:
Consistent with the basic guarantee, if you assign one std::vector to another and the copy operation fails, the contents of the target vector is not specified, but it is guaranteed to be a valid vector, so that if you happen to handle it later, you can safely do with it what you do with any other vector: you can insert or delete elements, iterate, whatever.
By analogy with your position, a better design for std::vector would be to define a special "error" state that you must check for *every* time you handle a vector, and the justification for that design is that otherwise it might be unexpected to see a vector in a half-copied (but valid, by definition) state. Do you see the practical difference now?
No, because vector already has that state -- it's called "a vector with size zero" (aka "empty"), which is the same state it typically transitions to when successfully moved-from. This is also the case for all the smart pointer types. I am saying that variant should behave exactly the same way. It's what people expect.