
4 Feb
2015
4 Feb
'15
5:02 p.m.
2015-02-04 15:54 GMT+04:00 Niall Douglas
There is also the possibility that is_trivial<T> is too conservative. Some may argue that is_trivially_copyable<T> would be sufficient. Thoughts?
There could be problems with alignment if a serialized data will be deserialized by other compiler. For example: struct A { int i, char c; }; struct B : public A { char c2[3]; int i2; }; Here structure B would be serialized differently by different compilers. sizeof(B) == 12 on GCC, some of the MSVC give 16. is_trivial<B> and is_trivially_copyable<B> would not be sufficient for that case. is_standard_layout<B> is required here. -- Best regards, Antony Polukhin