Subject: Re: [boost] [optional] memory use for optional refs and ptrs
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-10-06 17:15:15
On 10/06/10 13:19, Larry Evans wrote:
> On 10/06/10 13:05, Larry Evans wrote:
>> A copy of the code posted here:
>> followed by:
> Further experimentation resulted in the attached which produces output:
> So, gathering all tags at start (bools_A and chars_A) saves
> the most space.
The reason sizeof(A) == sizeof(bools_A) is that the 4 bools use
the padding following the int A::a. IOW, bools_A puts the
4 bools where the int A::a is located, followed by the int.
Hence, no extra space is needed. Adding 1 extra bool at the
start causes the sizeof(bools_A) to jump by 8.
This is shown by output of the attached:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk