std::is_standard_layout
Min standard notice:
Header: <type_traits>
std::is_standard_layout is a UnaryTypeTrait.
# Declarations
template< class T >
struct is_standard_layout;
(since C++11)
# Notes
A pointer to a standard-layout class may be converted (with reinterpret_cast) to a pointer to its first non-static data member and vice versa.
If a standard-layout union holds two or more standard-layout structs, it is permitted to inspect the common initial part of them.
The macro offsetof is only guaranteed to be usable with standard-layout classes.
# Example
#include <type_traits>
struct A { int m; };
static_assert(std::is_standard_layout_v<A> == true);
class B: public A { int m; };
static_assert(std::is_standard_layout_v<B> == false);
struct C { virtual void foo(); };
static_assert(std::is_standard_layout_v<C> == false);
int main() {}
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2015 | C++11 | T could be an array of incompleteclass type with unknown bound | the behavior isundefined in this case |