Boost logo

Boost :

From: Itay Maman (itay_maman_at_[hidden])
Date: 2002-08-09 12:31:21


"Anthony Williams" wrote in a message:

Anthony, please use plain-text mode for your post (rather than the HTML
format).

>
>Sorry, that's not what I meant. The variant would have _storage_ for two
instances, but only
>contain one at a time. When swapping the variants, you can copy-construct
the other variant into
>the unused space in this variant, then copy-construct this variant into the
unused space in the
>other one. If everything has succeeded, destruct the originals, and change
the flags. If anything
>failed, destruct the new copies (if any) and leave the flags alone.
>
>
[snip]
>
>Obviously, you need to account for alignment, and with variant it is a bit
more complex in the
>implementation due to the multiple types, but the idea is the same.
>
>Also, if you want assignment to actually perform assignment on the
underlying type, rather than
>just transfer the value into the variant, then things are more complicated.
>
>Anthony
>

Seems like a very reasonable compromise. I am certainly in favor of this
trick.
Anyway, this complicates the issue of safety vs. speed vs. sapce even
further.

Eric, Doug comments?

--
Itay Maman
    itay_maman@_yahoo_.com
    maman_at_il._ibm_.com
This message expresses my personal opinion.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk