|
Boost : |
Subject: Re: [boost] [proposal] raw move
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-08-24 00:53:14
on Tue Aug 23 2011, Ion Gaztañaga <igaztanaga-AT-gmail.com> wrote:
> El 23/08/2011 17:17, Christopher Jefferson escribió:
>
>> When moving was originally discussed, things like 'destructive' and
>> 'raw' moves were discussed, but it was decided in the end they were
>> too dangerous, without proving substantial benefits. For example, you
>> can rearrange a list of std::vectors with memcpy, but if you get half
>> way through and an exception is thrown and you end up with the same
>> vector left in two places in memory, horrible things will happen as
>> they will refer to the same memory block.
>
> IMHO, destructive move should be required always to be no-throw.
Destructive move is practically impossible to manage regardless of
exceptions:
void f()
{
SomeType x;
if (some_condition)
{
something_that_moves(x)
}
else
{
x.foo()
}
// Do we call x's destructor?
}
Even if you say the compiler can solve the problem in that trivial case
I can easily come up with slightly-less-trivial cases where the problem
arises and is absolutely intractable.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk