Boost logo

Boost :

Subject: Re: [boost] [type-traits] aligned_storage in unions
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-09-18 09:54:08


On 09/17/10 13:31, OvermindDL1 wrote:
> On Fri, Sep 17, 2010 at 9:46 AM, <dherring_at_[hidden]> wrote:
[snip]
>> 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.

Maybe Daniel doesn't want to pay for the extra memory
required by the which. At least that's the only reason
I can think of :(

So, Daniel, I've the same question as OvermindDl1.
Could you clarify "in-place"?

-regards,
Larry


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