I'd like to understand more about these types.
Instead of listing the requirements of a type to be trivial, standard layout, etc. I'd also like to know what it means to be trivial, standard layout, etc. Based on my understanding (which could be absolutely wrong), it's as below:
Trivially copyable – may be safely copied with std::memcpy. If you memcpy the data back to an object, it would be identical with the original object.
Trivial – trivially copyable, and has one or more default constructors, all of which are either trivial or deleted, and at least one of which is not deleted (must be trivial). Meaning it is trivially copyable, and statically initialized if we do default initialization (initialized at compile time, because the compiler knows the how default constructor works)
Standard layout – The layout (order of data members represented in memory, alignment, and the memory/padding size taken) is same as in C
POD – Trivial and standard layout. This type is fully compatible with C.
Please correct any misunderstanding I have, and provide references if possible.
Also, when do we want to create objects that are trivial, trivially copyable, standard layout, POD? Examples would be appreciated.