C++ Language Note:

POD Types

Walter E. Brown
September 29, 1999; last updated November 29, 1999

1.  Purpose

This note documents the definition of a POD type according to the International Standard for the C++ Programming Language [ISO/IEC 14882, first edition, 1998-09-01].  Related definitions are also provided, as is interpretive commentary on the significance of a POD-type.  All references herein are to the Standard.

2.  Definitions

The term POD is an acronym.  It stands for "plain old data" [p. 5, footnote 4], and is intended to suggest areas of substantive compatibility between comparable data types in C and C++.  The terms POD and POD object are often used interchangeably to refer to an object of POD type.

The term POD types collectively refers to the following categories of C++ types, and encompasses both cv-qualified versions of these as well as arrays of these [§3.9, ¶10; §9, ¶4]:

The term scalar types collectively refers to the following categories of C++ types, and encompasses cv-qualified versions of these [§3.9, ¶10]: The term arithmetic types collectively refers to the following categories of C++ types [§3.9.1, ¶8]: The term integral types collectively refers to the following C++ types [§3.9.1, ¶7]: The term floating types collectively refers to the C++ types float, double, and long double [§3.9.1, ¶8].

The term enumeration types collectively refers to distinct types, known as enumerations, that comprise sets of named constant values [§3.9.1, ¶1; §7.2, ¶1].

The term pointer types collectively refers to the following categories of C++ types [§3.9.2, ¶1]:

The term pointer-to-member types collectively refers to the following C++ types [§3.9.2, ¶1]: The term POD class types collectively refers to aggregate classes (POD-struct types) and aggregate unions (POD-union types) that have none of the following as members [§9, ¶4]: The term aggregate refers to an array or class that has none of the following characteristics [§8.5.1, ¶1]:
  • user-declared constructors,
  • private or protected non-static data members,
  • base classes, nor
  • virtual functions.
  • 3.  Commentary

    POD types have primary significance as an important source of compatibility with ANSI C code.  As such, objects of these types share several characteristics with their C equivalents.  These characteristics include initialization, copying, layout, and addressing.

    As an example of the sometimes-subtle distinction between POD and non-POD types, consider the initializations implied by each of the following new-expressions [§5.3.4, ¶15]:
     

    expression POD type T non-POD type T
     new T not initialized default-initialized
     new T() always default-initialized
     new T(x) always initialized via a constructor

    Thus, an object (or an array) of non-POD type is always guaranteed initialization, while an instance (or an array) of a POD type may be left uninitialized.

    Other POD-related C++ characteristics include the following:

    1. Layout
    2. Initialization
    3. Copying
    4. Addressing