$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] variant2 never empty guarantees (was: Re: Outcome/expected/etc/etc/etc)
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-12 17:29:19
Gottlob Frege wrote:
> On Wed, Jun 7, 2017 at 10:28 AM, Peter Dimov via Boost
> <boost_at_[hidden]> wrote:
> > Gottlob Frege wrote:
> >
> >> Agreed. But I don't see much value in the never-empty guarantee if it
> >> doesn't give you the strong guarantee.
> >
> >
> > I'm not sure I understand this fully; could you please explain from what
> > expressions, and under what conditions, you expect the strong guarantee?
> >
> > variant<X, Y> v1, v2;
> > X x;
> >
> > v1= v2; // do you expect strong guarantee here?
> > v1 = std::move(v2); // here?
> > v1 = x; // here?
> > v1 = std::move(x); // here?
> > v1.emplace<X>(); // here?
>
>
> How about "all of the above"?
> At least when X and Y each offer the strong guarantee?
I'm interested in a practical answer, not a theoretically sound one which is
of no use. Suppose that X is something that occurs in practice, such as
std::vector, not some hypothetical X with a strong assignment, which
doesn't.
Unless of course you only put types with strong assignment operators into
your variants, which in practice confines you to built-ins, in which case
all of the above will indeed be not just strong, but nonthrowing as well.