In C ++ 11, a type is considered a POD if it is
- trivial (scalar type, trivially copied class with trivial default constructor or an array of this type / class)
- standard layout (no virtual functions, no virtual base classes, etc.)
In principle, nothing that could interfere with copying objects, as if they consist only of raw bytes.
static_assert is to check something at compile time and does not change the layout of the object or triviality (or lack thereof)) when building, copying, etc. object. Therefore, adding any number of static statements to a type (struct / class) should not change its POD version.
You can check if the compiler is considering the POD type with std::is_pod<T>::value . This would not change before and after adding static_assert to it.
This is all the standard says about static_assert s. From [dcl.dcl] :
In a static_assert declaration, a constant expression must be a constant expression that can be contextually converted to bool . If the meaning of the expression, when it is converted, is true, the declaration is not valid. Otherwise, the program is poorly formed, and as a result, the diagnostic message (1.4) should contain the text of the string literal, except that the diagnostic message should not contain characters that are not contained in the basic character set of the source (2.3).
source share