I'm looking for solution to disable using as a template parameter structures that are POD (or say copyable) but has pointers. I'm going to send them over network. E.g.
// good
struct S1 {
int x;
S1() : x( 42 ) {} // I know that it's not a POD, but I know, that I can send S1 over network
};
// bad
struct S2 {
int *x;
};
template<typename POD>
class ToNetwork {
//static_assert( std::is_trivially_copyable< POD >::value, "Type must be POD" );
static_assert( std::is_standard_layout< POD >::value, "Type must be POD" );
POD m_payload;
};
ToNetwork< S1 > s1;
ToNetwork< S2 > s2; // should fail, but not((
Either is_trivially_copyable or is_standard_layout say that both structures are good.