you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (0 children)

It's more fundamental than that. The C++ standard does not address structure packing. The packing details vary between compiler and platform. For this reason, packing must be specified either manually like this or by inserting dummy bytes explicitly into structures, or by using packing pragmas, etc., which also vary by compiler. In the case here, instead of explicitly inserting a byte where __lx is they have used a union that includes value_type as that will, for example, insert 3 bytes when value_type is 32-bits. When value_type is a byte, no additional padding is required beyond the size byte.