Skip to content

Commit d396b32

Browse files
Dawn Perchikzygoloid
authored andcommitted
P1502R1 Standard library header units for C++20
Fixes #3020.
1 parent 40a941e commit d396b32

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

source/lib-intro.tex

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,23 @@
12801280
\tcode{<cwctype>} \\
12811281
\end{multicolfloattable}
12821282

1283+
\pnum
1284+
The headers listed in \tref{headers.cpp}, or,
1285+
for a freestanding implementation,
1286+
the subset of such headers that are provided by the implementation,
1287+
are collectively known as
1288+
the \defnadj{importable}{\Cpp{} library headers}.
1289+
\begin{note}
1290+
Importable \Cpp{} library headers can be
1291+
imported as module units\iref{module.import}.
1292+
\end{note}
1293+
\begin{example}
1294+
\begin{codeblock}
1295+
import <vector>; // imports the \tcode{<vector>} header unit
1296+
std::vector<int> vi; // OK
1297+
\end{codeblock}
1298+
\end{example}
1299+
12831300
\pnum
12841301
Except as noted in \ref{library} through \ref{\lastlibchapter}
12851302
and \ref{depr}, the contents of each header \tcode{c\placeholder{name}} is
@@ -1504,9 +1521,12 @@
15041521
The entities in the \Cpp{} standard library are defined in headers,
15051522
whose contents are made available to a translation unit when it contains the appropriate
15061523
\indextext{unit!translation}%
1507-
\tcode{\#include}
1508-
preprocessing directive\iref{cpp.include}.%
15091524
\indextext{\idxcode{\#include}}%
1525+
\tcode{\#include}
1526+
preprocessing directive\iref{cpp.include}
1527+
or the appropriate
1528+
\indextext{\idxcode{import}}%
1529+
\tcode{import} declaration\iref{module.import}.
15101530
\indextext{source file}
15111531

15121532
\pnum
@@ -1528,7 +1548,10 @@
15281548
\pnum
15291549
A translation unit shall include a header only outside of any
15301550
\indextext{unit!translation}%
1531-
declaration or definition, and shall include the header lexically
1551+
declaration or definition and,
1552+
in the case of a module unit,
1553+
only in its \grammarterm{global-module-fragment}, and
1554+
shall include the header or import the corresponding header unit lexically
15321555
before the first reference in that translation unit to any of the entities
15331556
declared in that header. No diagnostic is required.
15341557

source/modules.tex

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
The identifiers \tcode{module} and \tcode{import}
3535
shall not appear as \grammarterm{identifier}{s}
3636
in a \grammarterm{module-name} or \grammarterm{module-partition}.
37+
\indextext{module!reserved name of}%
38+
All \grammarterm{module-name}{s} beginning with an \grammarterm{identifier}
39+
consisting of \tcode{std} followed by zero or more \grammarterm{digit}{s} or
40+
containing a reserved identifier\iref{lex.name}
41+
are reserved and shall not be specified in a \grammarterm{module-declaration};
42+
no diagnostic is required.
43+
If any \grammarterm{identifier} in a reserved \grammarterm{module-name}
44+
is a reserved identifier,
45+
the module name is reserved for use by \Cpp{} implementations;
46+
otherwise it is reserved for future standardization.
3747
The optional \grammarterm{attribute-specifier-seq}
3848
appertains to the \grammarterm{module-declaration}.
3949

@@ -466,7 +476,8 @@
466476
\end{note}
467477
An \defnadj{importable}{header} is a member of an
468478
\impldef{how the set of importable headers is determined}
469-
set of headers.
479+
set of headers that
480+
includes all importable \Cpp{} library headers\iref{headers}.
470481
\tcode{H} shall identify an importable header.
471482
Two
472483
\grammarterm{module-import-declaration}{s}

0 commit comments

Comments
 (0)