|
Boost : |
From: Eric Friedman (ebf_at_[hidden])
Date: 2003-09-01 02:35:31
Alexander Nasonov
> Eric Friedman wrote:
> > But suppose I have a variant v3, with content of a different type (call
it
> > T3). Then the assignment v1 = v3 is far more complicated (we can't use
> > T1::operator=) and, without double storage, far more dangerous. The
single
> > storage implementation behaves as follows:
> >
> > destroy v1 content
> > copy v3 content into v1
>
> Assuming that memcpy to new location followed by memcpy back to original
> allocation is safe, you would do it using two additional storages local to
> operator= function. Let's call them local1 and local2.
[snip]
If I understand you correctly, earlier versions of variant did precisely
what you describe. Unfortunately, the "assumption" you make is false in
general. See http://aspn.activestate.com/ASPN/Mail/Message/boost/1311813.
Eric
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk