From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-10-09 15:45:53
On Thursday 09 October 2003 04:17 pm, E. Gladyshev wrote:
> --- Douglas Gregor <gregod_at_[hidden]> wrote:
> > Please do note that you are refuting something that is considered to have
> > already been proven in prior discussions, which have been cited. In this
> > circumstance, the burden of proof falls on you.
> I read his message. I don't see any prove there just a statement from
> the standard that doesn't prove anything.
> I repeat it again all my code is doing is copying one char
> to another char. Both variables have been allocated
> as char originally there is not any casting going on.
I'll spell it out, then. Your code starts with:
variant_copy( b1, data_, size );
//place new object in _data
T* obj = new(data_) T;
At the line
T* obj = new (data_) T;
you've ended the lifetime of the object that used to be in data_. The clauses
David A. quotes state that specifically. It doesn't matter that you saved the
bits at that location, because the object's lifetime has ended when the
storage was reused (by constructing a new object there): you can't bring it
back to life by copying the bits back where the object should be. It's okay
for POD types, but not for non-POD types.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk