Skip to content

[class.prop] standard-layout class type requirements are hard to read #7593

Open
@Eisenwave

Description

@Eisenwave

I find that https://eel.is/c++draft/class.prop#2.7 is pretty hard to read in its current state:

draft/source/classes.tex

Lines 208 to 230 in 0ca05d2

\begin{itemize}
\item If \tcode{X} is a non-union class type with no non-static data members,
the set $M(\mathtt{X})$ is empty.
\item If \tcode{X} is a non-union class type with a non-static data
member of type $\mathtt{X}_0$
that is either of zero size or
is the first non-static data member of \tcode{X}
(where said member may be an anonymous union),
the set $M(\mathtt{X})$ consists of $\mathtt{X}_0$ and the elements of
$M(\mathtt{X}_0)$.
\item If \tcode{X} is a union type, the set $M(\mathtt{X})$ is
the union of all $M(\mathtt{U}_i)$ and the set containing all $\mathtt{U}_i$,
where each $\mathtt{U}_i$ is the type of the $i^\text{th}$ non-static data member
of \tcode{X}.
\item If \tcode{X} is an array type with element type $\mathtt{X}_e$,
the set $M(\mathtt{X})$ consists of $\mathtt{X}_e$
and the elements of $M(\mathtt{X}_e)$.
\item If \tcode{X} is a non-class, non-array type, the set $M(\mathtt{X})$ is empty.
\end{itemize}

For starters, we can replace the first and last bullet like:

-\item If \tcode{X} is a non-union class type with no non-static data members, 
-the set $M(\mathtt{X})$ is empty. 
 [...]
-\item If \tcode{X} is a non-class, non-array type, the set $M(\mathtt{X})$ is empty.
+Otherwise, the set $M(\mathtt{X})$ is empty.

I may draft up an actual PR for this soon, but I'm still pondering on how to fully simplify this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions