I try to understand the POD concept in terms of other type predicates.
Is there a complete list of type predicates that would correspond to std::is_pod<>
?
Here is my current attempt which does not hold (VS2013).
struct C { // Does not assert as POD class
int value;
C() = default;
C(int v) : value(v) { // Offends is_pod<>
}
};
static_assert(std::is_trivial<C>::value, ""); // Assert OK
static_assert(std::is_trivially_copyable<C>::value, ""); // Assert OK
static_assert(std::is_standard_layout<C>::value, ""); // Assert OK
static_assert(std::is_pod<C>::value, ""); // Assert fails. Why?
The combination of is_trivial
and is_standard_layout
is equal to is_pod
, modulo some other restrictions on non-static members that are not captured by one of the type traits in <type_traits>
.
Relevant quote from the draft Standard:
[class]
10 A POD struct is a non-union class that is both a trivial class and a standard-layout class, and has no non-static data members of type non-POD struct, non-POD union (or array of such types). Similarly, a POD union is a union that is both a trivial class and a standard-layout class, and has no non-static data members of type non-POD struct, non-POD union (or array of such types). A POD class is a class that is either a POD struct or a POD union.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With