RAD Studio
ContentsIndex
PreviousUpNext
__is_standard_layout

Category 

Type Trait Functions 

Syntax 

bool __is_standard_layout(typename T) 

Returns true if and only if T is a standard layout type. 

Error if T is an incomplete type. 

Standard layout classes are defined in Section 9, p 6 of the Working Draft. 

A standard layout type is:

  • a scalar type
  • an array of standard layout types
  • a standard layout class type:
A standard layout class is a class that has:
  • no non-static data members other than standard layout types
  • same access control for all non-static data members (such as all public or private)
  • no base classes other than standard layout classes
  • no virtual functions and no virtual base classes
  • no more than one class in the DAG of inheritance tree has any non-static data
  • no base class of same type as the first (if any) non-static data member
Standard layout types trigger several special clauses in the standard, which may affect code generation and optimizations, or simply whether certain constructs are undefined. In particular, standard layout classes require the empty base optimization.  

Note that standard layout types are a generalization of PODs in the 2003 standard, if the POD/standard layout refinement has not happened when this type function is initially implanted.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!