Subject: Re: [boost] [optional] memory use for optional refs and ptrs
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-10-07 09:25:19
On 10/07/10 06:22, Stewart, Robert wrote:
> I was suggesting that this:
> struct P
> short s;
> char c;
> short t;
> char d;
> could occupy less space than if the chars and shorts were reversed.
> That is, that P::c could occupy padding between P::s and P::t and
> P::d could occupy padding between a P instance and something
> following it in another composite. Doing so would not violate an
> ABI, unless the ABI specifically disallowed it, because it can be
> established as the expected layout in those cases.
produces output shown in the attachment.
tagPs is with char's first, Ptags is iwht char's 2nd.
Both sizes are same:
the other output shows the alignments and offsets of each
component was well as the padding. The offsets are listed
starting from last to first element in the structs.
the output prefixed with layout0 shows the layout for
an empty struct.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk