$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [type-traits] aligned_storage in unions
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-09-17 15:18:38
On Fri, Sep 17, 2010 at 1:12 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> OvermindDL1 wrote:
>>
>> On Fri, Sep 17, 2010 at 9:46 AM, Â <dherring_at_[hidden]> wrote:
>>
>>>
>>> On Fri, 17 Sep 2010, Frank Mori Hess wrote:
>>>
>>>>
>>>> What about using boost.variant instead?
>>>>
>>>
>>> It doesn't satisfy my need for everything to be in-place (e.g. for
>>> seamless
>>> use with shared memory, memory pools, etc.). Â [Note: we don't actually
>>> use
>>> std::string; it was just convenient for the example.]
>>>
>>
>> How is it not in-place?
>>
>> If C++ supported unions containing anything, then
>> boost::variant<int,std::string,myClass> would be identical in layout
>> to:
>> struct {
>> Â Â uint which;
>> Â Â union {
>> Â Â Â Â int i;
>> Â Â Â Â std::string s;
>> Â Â Â Â myClass m;
>> Â Â }
>> }
>> Which all use the same memory.
>
> boost::variant can use the heap in some cases,
> to preserve exception safety.
And when using recursive structures that do not manage their own recursiveness.