Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-08-09 12:02:05


On Friday 09 August 2002 01:31 pm, Itay Maman wrote:
> >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?

I think it's interesting to note that this trick could come "for free" if
there is a large type that can always be swapped/assigned giving the strong
guarantee and a smaller type that doesn't have such properties. For instance:

  variant<double[5], crazy_type> v;

where crazy_type is a type with strange behavior, but whose size is less than
the size of 2 doubles.

        Doug


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