POD

Walter Bright newshound2 at digitalmars.com
Fri Dec 28 20:51:17 PST 2012


On 12/28/2012 7:37 PM, Andrei Alexandrescu wrote:
> On 12/28/12 10:12 PM, Walter Bright wrote:
>> For example, C++ disallows mixed public/private data in a POD. I've
>> never understood the reason for that restriction other than "C doesn't
>> have private fields". D doesn't propagate that aspect.
>
> The idea was to leave C++ compilers to change the order of fields in classes
> with private data for optimal layout. I don't know of any compilers that do, but
> that was the intent. PODs were not susceptible to such layout optimization
> because they had to be compatbile with C's layout.

I didn't know that, but it makes sense.

Interestingly, D's original design allowed fields in classes to be rearranged. 
This kind of fell by the wayside with the align directive.



More information about the Digitalmars-d mailing list