
6 Oct
2010
6 Oct
'10
6:05 p.m.
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