The document you referenced prety says a lot about requirements:
is_trivially_copyable<T>::value && is_standard_layout<T>::value && is_contiguous_layout<T>::value
which must have true recursion for the structure itself and all its members.
The first two checks are already included in the standard library, and you can implement is_contiguous_layout<T>::value yourself. As a basis, it should be enough to compare the sum of the sizes of its members with the size of the structure itself. I do not think offset verification is really necessary.
This, of course, should work on "regular" platforms ( CHAR_BIT == 8 , 2-complement), if your type consists only of integer types. I am not sure, however, if it also works with bools and floating point numbers, since I believe that the standard does not provide an unambiguous two-way comparison between the value of a variable and its representation in bits.
EDIT: I just realized that you cannot fulfill the condition of same most derived type if no elements are added to the derived class, or if you are comparing two different classes that have the same members. Therefore, you will have to consider the type separately.
source share