|
Boost : |
From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2003-08-30 03:28:21
"Eric Friedman" <ebf_at_[hidden]> wrote in message
news:bip114$h5p$1_at_sea.gmane.org...
> 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
You can do this:
destroy v1 content
try to copy v3 content into v1
if that fails, initialize v1 with default c'tor and rethrow
I believe that's what my original Variant does. This creates the
requirement that the default constructor doesn't throw, which is quite
unnerving but imho much less than the double storage requirement - one that
I found so disappointing, I needed to read it twice thinking/hoping I
misunderstood.
Andrei
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk