Boost logo

Boost :

Subject: Re: [boost] [interprocess] default constructors
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-12-05 19:00:27

David Abrahams wrote:
> on Wed Dec 03 2008, Mathias Gaunard <> wrote:
>> David Abrahams wrote:
>>> I don't think it's unfortunate. Destructive move semantics is nearly
>>> impossible to use correctly in many conditions.
>> Would you mind giving examples?
> void f()
> {
> X a;
> if (something)
> g(move(a));
> // ...
> // a.~X() ?
> }

Indeed, in the general case, the compiler (this certainly shouldn't be
the job of the programmer) would have to transform the code to something
like that:

void f()
     X a;
     bool destruct_a = true;

     if (something)
         destruct_a = false;
     // ...

     if (destruct_a)

Usual const-propagation should be enough to optimize those booleans out
when possible.

It's true however the current system is really much simpler since there
is no such work required for the compiler (and maybe it can be optimized
just as well?)

Boost list run by bdawes at, gregod at, cpdaniel at, john at