I have a class like:
Fragment 1:
struct B
{
int member;
};
This class is used in code, assuming it is a C style structure (e.g. used in memcpy , memset , etc.)
As part of good programming principles, I consider modification B as follows:
Fragment 2
struct B
{
B() {}
int member;
};
Here is my understanding. Please correct if I am wrong a. Fragment 1 defines B, which is POD, while Snippet 2 defines B, which is not POD, AND b. In Snippet 2, B can still be legally used for C-style use like memset and memcpy
- std :: is_pod: false
- std :: is_trivial: false
- std :: is_trivially_copyable: true
- std :: is_trivial: false
, Big 3 (, , Big 5), , .
3:
struct B
{
B() {}
~B(){}
B& operator=(B &){ return *this; }
B(B const &r){}
int member;
};
. , ,
. Snippet 3 B C, memset memcpy
- std:: is_pod: false
- std:: is_trivial: false
- std:: is_trivially_copyable: false
- std:: is_trivial: false
B Snippet 2 Snippet 3 C. .
C is_trivially_copyable is_trivial ( )?
$3.9/2 , ++ 11 "is_trivially_copyable" . ++ (++ , , ) , POD vs non POD, , ++ 11 .
Petes, , ,