Boost logo

Boost :

Subject: Re: [boost] A Pimpl variant
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2010-04-03 00:15:07

On Fri, Apr 2, 2010 at 11:14 AM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> Can't you just use boost::aligned_storage?
> In Christ,
> Steven Watanabe

That would definitely help (can't recall if it was around back then).
Either way, it doesn't solve the other problem of "I have a 12 byte
object, what is its worse-case alignment?" I would guess 8, given
today's machines, and align it to a double.

Actually, no. I always start thinking that way, then realize I'm
wrong. The alignment would be 4 (for today's typical machine). ie
the largest sizeof(primitive_type) such that it divides into the size.

And now that I think about it, maybe there is no reason to not use
alignment of 12. Same diff I suppose.

So maybe aligned_storage<12, 12> is all I need.

I now I can't remember if the original hard problem was getting an
answer of 8 given a size of 12 (which is wrong anyhow) or whether I'm
forgetting some detail that bit me later.

So a question. Given:

struct {
    int a, b, c;

is there any difference saying it has an alignment of 12 vs an
alignment of 4? (assuming sizeof(int) == 4)?

And/or is there any difference between boost::aligned_storage<12, 4>
and boost_aligned_storage<12, 12>?


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