Given a struct that contains a sequence of the same fundamental types, like this:
struct Vector { float x; float y; float z; }; Can it have padding between the members? I was given the link to [class.mem] that says that padding may be added to achieve alignment but is it applicable in this case?
static_assertto check at compile time. For example,static_assert(sizeof(Vector) == sizeof(float) * 3, "");.Vectormemberssizeof(Vector)is three floats, and we know that aVectorcontains at least 3 floats, then that doesn't leave a single byte anywhere for padding.