We have the following method to test if our structure is a POD or not. It always returns true:
bool podTest() {
struct podTest {
int count;
int x[];
};
return std::is_pod<podTest>::value; //Always returns true
}
So far so good. Now we make one change and delete the copy constructor:
bool podTest() {
struct podTest {
podTest(const podTest&) = delete;
int count;
int x[];
};
return std::is_pod<podTest>::value; //Always returns false
}
This always returns false. After reading over the definition of is_pod
I am still struggling to understand what requirement it violates. What am I missing?
This is being compiled on godbolt using gcc 6.1, with -std=c++14
std::is_trivially_copyable<podTest>::value
returns true, so there must be some other violation of POD requirements. Certainlyint x[];
should be removed. Unless I'm mistaken, flexible array bounds aren't part of C++14. – Topknotstd::is_pod
with a compiler hook it seems, not via thestd::is_trivially_copyable
. libc++ also uses the compiler hook if available, but its fallback implementation is wrong too because Trivially Copyable is not the same as (Trivially Copy Constructible && Trivially Copy Assignable), which is what they check for. – Hibernal