|
Boost : |
Subject: Re: [boost] [optional] memory use for optional refs and ptrs
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-10-06 14:05:40
On 10/06/10 08:28, Sebastian Redl wrote:
> On 06.10.2010 14:26, Stewart, Robert wrote:
[snip]
>> When the bool follows the value, it can occupy otherwise unused
>> padding between data members.
>>
> I really don't think so. Maybe in theory, but not in practice,
[snip]
A copy of the code posted here:
http://article.gmane.org/gmane.comp.lib.boost.devel/209212
followed by:
struct C {
int a;
bool ta;
double b;
bool tb;
double c;
bool tc;
std::string d;
bool td;
};
int main(void)
{
std::cout<<"sizeof(A)="<<sizeof(A)<<"\n";
std::cout<<"sizeof(B)="<<sizeof(B)<<"\n";
std::cout<<"sizeof(C)="<<sizeof(C)<<"\n";
return 0;
}
showed sizeof(B) = sizeof(C), justifying Sebastian's doubt.
-Larry
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk