- Title
- Definition and usage of structure, POD-struct, POD-union, and POD class
- Status
- cd1
- Section
- Clause [11] [class]
- Submitter
- Alisdair Meredith
Created on 2005-08-10.00:00:00 last changed 217 months ago
Messages
Date: 2007-04-15.00:00:00
[Voted into WP at April, 2007 meeting.]
Date: 2006-04-15.00:00:00
Proposed resolution (April, 2006): Change Clause 11 [class] paragraph 4 as indicated: Change 11.8.3 [class.access.base] paragraph 2 as indicated: Delete the note in 7.6.1.5 [expr.ref] paragraph 4: Change the commentary in the example in 11.4 [class.mem] paragraph 11
as indicated: ...an integer, and two pointers to ...the count member of the Change _N4567_.17.3 [definitions] “iostream class
templates” as indicated: Change 17.6 [support.dynamic] paragraph 4 as indicated: Change the third bullet of Clause Annex B [implimits] paragraph 2 as
indicated:
Pointer, array, and function declarators (in any combination)
modifying Change the nineteenth bullet of Clause Annex B [implimits] paragraph 2
as indicated:
Data members in a single class Change the twenty-first bullet of Clause Annex B [implimits] paragraph 2
as indicated:
Levels of nested class Change C.9 [diff.library] paragraph 6 as indicated: Change the last sentence of 6.9 [basic.types] paragraph 10
as indicated:
Drafting note: Do not change 6.9 [basic.types] paragraph 11,
because it's a note and the definition of
“layout-compatible” is separate for POD-struct and
POD-union in 11.4 [class.mem]. (This resolution also resolves issue 327.)
A structure is a class defined with
the class-key struct ; its members and base classes
(11.7 [class.derived]) are public by default (
11.8 [class.access]). A union is a class defined with the
class-key union ; its members are public by default
and it holds only one data member at a time (11.5 [class.union]). [Note: aggregates of class type are described
in 9.5.2 [dcl.init.aggr]. —end note]
A POD-struct is an aggregate class that has no non-static
data members of type non-POD-struct, non-POD-union (or array of such
types) or reference, and has no user-declared copy assignment operator
and no user-declared destructor. Similarly, a POD-union is an
aggregate union that has no non-static data members of type
non-POD-struct, non-POD-union (or array of such types) or reference,
and has no user-declared copy assignment operator and no user-declared
destructor. A POD class is a class that is either a POD-struct
or a POD-union. A POD class is an aggregate class that
has no non-static data members of non-POD type (or array of such a
type) or reference, and has no user-declared copy assignment operator
and no user-declared destructor. A POD-struct is a POD class
defined with the class-key struct or
the class-key class . A POD-union is a POD class
defined with the class-key union .
In the absence of an access-specifier for a base
class, public is assumed when the derived class is
declared defined with
the class-key struct and private is
assumed when the class is declared defined with the
class-key class . [Example:...
[Note: “class objects” can be structures
(11.4 [class.mem]) and unions (11.5 [class.union]). Classes are discussed in Clause 11 [class].
—end note]
similar structures
objects of the same type. Once this definition...structure object
to which sp points; s.left refers to
the left subtree pointer of the structure
object s ; and...
...the argument traits is a
structure class
which defines additional characteristics...
If type is not a
POD structure or a POD union
POD class (clause 9), the results are undefined.
an a class, arithmetic, structure,
union, or incomplete type in a declaration [256].
, structure, or union [16 384].
, structure, or union definitions in a
single struct-declaration-list
member-specification [256].
The C++ Standard library provides 2 standard
structures
struct s from the C library, as shown in Table 126.
Scalar types,
POD-struct types, POD-union types POD
classes (Clause 11 [class]), arrays of such types
and cv-qualified versions of these types (6.9.6 [basic.type.qualifier]) are collectively called
POD types.
Date: 2026-07-25.21:52:10
There are several problems with the terms defined in
Clause 11 [class] paragraph 4: Although the term structure is defined here, it is
used only infrequently throughout the Standard, often apparently
inadvertently and consequently incorrectly: 7.6.1.5 [expr.ref] paragraph 4: the use is in a
note and is arguably correct and helpful. 11.4 [class.mem] paragraph 11: the term is used
(three times) in an example. There appears to be no reason to use
it instead of “class,” but its use is not
problematic. _N4567_.17.3 [definitions] “iostream class templates:”
the traits argument
to the iostream class templates is (presumably unintentionally)
constrained to be a structure, i.e., to use the struct
keyword and not the class keyword in its definition. Clause Annex B [implimits] paragraph 2: the minimum number of
declarator operators is given for structures and unions but not
for classes defined using the class keyword. Clause Annex B [implimits] paragraph 2: class, structure,
and union are used as disjoint terms in describing nesting
levels. (The nonexistent nonterminal struct-declaration-list
is used, as well.) There does not appear to be a reason for defining the term
structure. The one reference where it is arguably useful,
in the note in 7.6.1.5 [expr.ref], could be rewritten
as something like, “'class objects' may be defined using the
class , struct , or union
class-keys; see Clause 11 [class].” Based on its usage later in the paragraph and elsewhere,
“POD-struct” appears to be intended to exclude unions.
However, the definition of “aggregate class” in
9.5.2 [dcl.init.aggr] paragraph 1 includes unions.
Furthermore, the name itself is confusing, leading to the question of
whether it was intended that only classes defined
using struct could be POD-structs or
if class -classes are included. The definition should
probably be rewritten as, “A POD-struct is an aggregate
class defined with the class-key struct or
the class-key class that has no... In most references outside Clause 11 [class],
POD-struct and POD-union are mentioned together and treated
identically. These references should be changed to refer to the
unified term, “POD class.” Noted in passing: 17.2 [support.types] paragraph 4
refers to the undefined terms “POD structure” and
(unhyphenated) “POD union;” the pair should be replaced
by a single reference to “POD class.”
A structure is a class defined with
the class-key struct ; its members and base classes
(11.7 [class.derived]) are public by default (
11.8 [class.access]). A union is a class defined with the
class-key union ; its members are public by default and
it holds only one data member at a time (11.5 [class.union]). [Note: aggregates of class type are described
in 9.5.2 [dcl.init.aggr]. —end note]
A POD-struct is an aggregate class that has no non-static data
members of type non-POD-struct, non-POD-union (or array of such types)
or reference, and has no user-declared copy assignment operator and no
user-declared destructor. Similarly, a POD-union is an
aggregate union that has no non-static data members of type
non-POD-struct, non-POD-union (or array of such types) or reference,
and has no user-declared copy assignment operator and no user-declared
destructor. A POD class is a class that is either a POD-struct
or a POD-union.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
| 2007-08-05 00:00:00 | admin | set | status: dr -> wp |
| 2007-05-06 00:00:00 | admin | set | messages: + msg1505 |
| 2007-05-06 00:00:00 | admin | set | status: ready -> dr |
| 2006-11-05 00:00:00 | admin | set | status: review -> ready |
| 2006-04-22 00:00:00 | admin | set | messages: + msg1325 |
| 2006-04-22 00:00:00 | admin | set | status: open -> review |
| 2005-08-10 00:00:00 | admin | create | |