< cpp‎ | types
Revision as of 21:55, 8 April 2013 by Cubbi (Talk | contribs)

Type support
Type properties
Supported operations
Relationships and property queries
Type modifications
Type transformations
Type trait constants

Template:ddcl list begin <tr class="t-dsc-header">

Defined in header <type_traits>

<td></td> <td></td> <tr class="t-dcl ">

<td >
template< class T >
struct is_standard_layout;

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

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

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

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>


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.


#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';



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]