Boost logo

Boost :

Subject: Re: [boost] [type-traits] aligned_storage in unions
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-09-20 12:07:41


  AMDG

On 9/20/2010 8:50 AM, dherring_at_[hidden] wrote:
> See
> http://www.boost.org/doc/libs/1_44_0/doc/html/variant/design.html
>
> In particular, "Temporary Heap Backup" and "Future Direction".
>
> We have some specialized requirements. We couldn't even use
> boost::shared_ptr until it added both the custom allocator and
> deleter. The "never-empty guarantee" conflicts with our needs and is
> not a concern at this time.

You can effectively bypass the never-empty guarantee by adding
boost::blank to the variant types. This will cause the variant to
set itself to boost::blank on an exception instead of using heap
backup. (This will actually work if has_nothrow_constructor is
true for /any/ of the variant types, but boost::blank is the preferred
backup if it's present.).

> As a side note, we also must expose both the type of the "which" and
> the discriminant to member mapping (which may be N:1; see the CORBA
> IDL spec). So I believe boost::variant would still be hard to use even
> if the heap issue were resolved.

In Christ,
Steven Watanabe


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