< cpp‎ | types
Type support
Type properties
Supported operations
Relationships and property queries
Type modifications
Type transformations
Type trait constants
Defined in header <type_traits>
template< class T >
struct is_standard_layout;
(since C++11)

If T is a standard layout type (that is, a scalar type, a standard-layout class, or an array of such type/class, possibly cv-qualified), provides the member constant value equal true. For any other type, value is false.

A standard-layout class is a class that satisfies StandardLayoutType, that is

1. has no non-static data members that aren't standard-layout or reference

2. has no virtual functions and no virtual base classes

3. has the same access control for all non-static data members

4. has no base classes that aren't standard-layout

5. either has no base class with non-static data members or has no non-static data members in the most derived class and only one base with them

6. has no base classes of the same type as the first non-static data member


Inherited from std::integral_constant

Member constants

true if T is a standard-layout type , false otherwise
(public static member constant)

Member functions

operator bool
converts the object to bool, returns value
(public member function)
returns value
(public member function)

Member types

Type Definition
value_type bool
type std::integral_constant<bool, value>

[edit] 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 can only be used with standard-layout classes.

[edit] Example

#include <iostream>
#include <type_traits>
struct A {
    int m;
struct B {
    int m1;
    int m2;
struct C {
    virtual void foo();
int main()
    std::cout << std::boolalpha;
    std::cout << std::is_standard_layout<A>::value << '\n';
    std::cout << std::is_standard_layout<B>::value << '\n';
    std::cout << std::is_standard_layout<C>::value << '\n';



[edit] See also

checks if a type is trivially copyable
(class template) [edit]
checks if a type is plain-old data (POD) type
(class template) [edit]
byte offset from the beginning of a standard-layout type to specified member
(function macro) [edit]
variable template alias of std::is_standard_layout::value
(variable template) [edit]