Niall Douglas wrote:
I hate with a passion any possibility of a variant changing its state without me explicitly telling it to do so. The only tolerable state a variant should ever choose on its own is empty/valueless.
I wonder whether the people who insist on the strong guarantee on assignment realize that when the variant holds a vector, and you assign it a vector, assignment delegates to vector<>::operator= and as a result you get the basic guarantee because that's what all standard types provide. That is, the "variant state" - by which you probably mean the index - doesn't change but the variant state can change into holding a vector that is neither the old nor the new one. It's possible to define a variant that never delegates to the assignment operator of the contained type. I've also argued for this possibility, because it makes it possible for one to put non-assignable types into variant (and optional, if it's changed to match), and still get an assignable variant. Nevertheless, this is not the case today, and I suspect that you don't realize that the strong guarantee requires this change.
1. If at least all types minus one have nothrow move construction, you get the strongest possible never empty never change guarantee.
What do you do on emplace