From: Rainer Deyke (rainerd_at_[hidden])
Date: 2003-10-09 17:45:11
E. Gladyshev wrote:
> Sorry, I meant your code.
> The problem is that B's default constructor breaks
> in this particular.
> When your write v = B(, boost::variant use
> placement 'new' (as it should).
> The placement 'new' will render the the_A invalid
> (in a sense it not pointing to A any more),
> the B() constructor tries to use the invalid the_A.
> It is where it break. It has nothing to do with
> the trick.
This should not happen because the 'A' object should be properly destroyed
before the 'B' object is constructed at the same location. It is undefined
behavior for 'variant' to construct the new 'B' object in a memory location
that is already occupied by the 'A' object. The problem is not with
placement 'new', it is with overlapping lifetimes of objects at the same
-- Rainer Deyke - rainerd_at_[hidden] - http://eldwood.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk