With the introduction of c++11, trivially copyableness has gotten quite relevant. Most notably in the use of 'std::atomic'. The basics are quite simple. A class foo
is trivially copyable if:
foo* src = new foo();
foo* dest = malloc(sizeof(foo));
memcpy(dest, src, sizeof(foo));
Has the same effect as:
foo* src = new foo();
foo* dest = new foo(src);
So an object where copying the memory will have the same effect as a copy constructor. However there, of course, is a catch. There's not only copy constructors. But also move constructors, move assignment operators. Etc.
std::is_trivially_copyable can be used to test whether an object is trivially copyable. So with trial and error it is possible to make an object trivially copyable.
But of course a well defined set of rules would be a bit nicer:). So hereby my request.
The most well-defined set of rules would come directly from the standard. Here are the relevant entries from standard draft N4296:
Trivially-copyable types are defined in [basic.types]/9
Trivially-copyable classes are defined in [class]/6
Copy/move constructors in [class.copy]/12
Copy/move assignment operators in [class.copy]/25
Destructors in [class.dtor]/5
User-provided constructors in [dcl.fct.def.default]/5
The short answer is that the short answer is sometimes more helpful than the long answer.