r/cpp • Meeting C++ | C++ Evangelist • Sep 24 '26

About alignment, struct layout and the cache...

https://meetingcpp.com/blog/items/About-alignment--struct-layout-and-the-cache---.html
36 Upvotes

27 comments sorted by

View all comments

Show parent comment

2

u/friedkeenan Sep 26 '26

I don't think that's the same as if it has padding bytes. For one, the type also needs to be trivially copyable for it to yield true, but also a type can have no padding bytes and still not have unique object representations. For instance, for floating-point types, a NaN value can be represented by multiple different bitwise representations, and so this trait will yield false for floats.

1

u/pavel_v Sep 27 '26

You're right.