Boost logo

Boost :

Subject: Re: [boost] [variant] Please vote for behavior
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-01-28 09:34:56


On Mon, Jan 28, 2013 at 6:10 PM, Paul Smith <pl.smith.mail_at_[hidden]> wrote:
>
> Then you're still thinking in terms of destructive move. The reason
> why you don't see a problem with a "singular valued" recursive_wrapper
> (that's what we call it now? :-) is that you don't think anyone will
> try to use it. And, c'mon, it's not just a matter of documentation -
> we're not trying to weasel our way out of this. Adding a new and
> entirely different state just for the sake of move construction is a
> polite way of ignoring the possiblity that moved-from objects will be
> used. It might win you a case in court, but it's completely missing
> the point.

I'm still missing a use case when a moved-from variant will be used in
a previously-working code. It has been stated that variant did not
support move so it was copied where it could have been moved before
the change. The implicit moving of temporaries seem to pose no
problems because temporaries are not used after move. The change will
affect cases of explicit move of (non-temporary) variants but it seems
unlikely if the code attempts to use the source object after move.
Someone suggested that problems can arise with associative containers,
but I fail to see how that can happen, keeping in mind that the key is
always constant and cannot be moved.

So unless I missed something, we're arguing about cases like this:

  variant< ... > v;
  foo(move(v));
  cout << v;

Am I correct?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk