Boost logo

Boost :

Subject: Re: [boost] several messages
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2012-08-05 07:39:35

On Sun, 5 Aug 2012, John Maddock wrote:

>> Uh?
>> This is indeed what happens, but for GMP types, unless you added in your
>> wrapper a special 0 state (which you then have to test in every operation),
>> every constructor has to allocate, including the move constructor, since a
>> moved-from object must still be in a valid state.
>> Did you add an empty state then?
> The move constructor doesn't allocate - it takes ownership of the GMP
> variable, and sets the variable in the moved-from object to a null state. The
> *destructor* then has an added check to ensure it doesn't try and clear null
> GMP objects: that's basically the only change. IMO the cost of the extra if
> statement in the destructor is worth it - and should be trivial compared to
> calling the external library routine to clear the GMP variable.

Well, what happens then if you do something to a moved-from object other
than destructing it?

number a=2;
number b=move(a);
a=2; // or a=b; or a=b+1; or ...

Marc Glisse

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