c++ - Why is this not a POD? -


this std::is_pod, detects whether template plain old data type or not.

see following code:

struct { public:     int m1;     int m2; };  struct b { public:     int m1; private:     int m2; };  struct c { private:     int m1;     int m2; };  int main() {     std::cout << std::boolalpha;     std::cout << std::is_pod<a>::value << '\n'; // true     std::cout << std::is_pod<b>::value << '\n'; // false     std::cout << std::is_pod<c>::value << '\n'; // true } 

the 3 structs pod me. apparently struct b not. don't understand why. me, have trivial constructor, move , copy operator. destructor trivial too.

i blame on using 2 access specifiers, can't find information this.

according standard (9 classes [class], emphasis mine):

a standard-layout class class that:

...

has same access control (clause 11) for non-static data members,

...

and

a pod struct non-union class both trivial class , a standard-layout class, , ...

your hunch correct, because b.m1 , b.m2 both non-static , have different access control.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -