Boost logo

Boost :

From: Anthony Williams (anthony.williamsNOSPAM_at_[hidden])
Date: 2003-10-27 05:17:12

Eric Friedman <ebf_at_[hidden]> writes:
> Double storage has been replaced by the above-described temporary heap
> backup strategy so as to incur overhead only when/if variant assignment
> occurs (vs. the constant space inefficiency incurred by double storage).

I obviously missed the discussion where this was decided; I don't like this
solution. I felt that a strong part of the design was that no heap storage was
used, and so using it for assignment violates that principle, and is IMO

> Heap backup will not be used for assignment to a variant if the content type
> of the right-hand side is nothrow copyable.
> As well, heap backup will never be used for assignment to a
> variant<T1,...,TN> if *any* of its bounded types Ti are nothrow
> default-constructible. (Note, this is regardless of the content of the
> right-hand side.)

This, OTOH, seems thoroughly sensible. You don't want overhead that you don't
need, and you only want the basic guarantee.

If users don't want double-storage, then they can supply a
no-throw-default-constructible type (such as boost::empty) as a valid variant
type, or they can use something like boost::any if heap storage is acceptable.


Anthony Williams
Senior Software Engineer, Beran Instruments Ltd.
Remove NOSPAM when replying, for timely response.

Boost list run by bdawes at, gregod at, cpdaniel at, john at