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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Module units and purviews <a id="module.unit">[[module.unit]]</a>
|
| 2 |
+
|
| 3 |
+
``` bnf
|
| 4 |
+
module-declaration:
|
| 5 |
+
export-keywordₒₚₜ module-keyword module-name module-partitionₒₚₜ attribute-specifier-seqₒₚₜ ';'
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
``` bnf
|
| 9 |
+
module-name:
|
| 10 |
+
module-name-qualifierₒₚₜ identifier
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
``` bnf
|
| 14 |
+
module-partition:
|
| 15 |
+
':' module-name-qualifierₒₚₜ identifier
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
``` bnf
|
| 19 |
+
module-name-qualifier:
|
| 20 |
+
identifier '.'
|
| 21 |
+
module-name-qualifier identifier '.'
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
A *module unit* is a translation unit that contains a
|
| 25 |
+
*module-declaration*. A *named module* is the collection of module units
|
| 26 |
+
with the same *module-name*. The identifiers `module` and `import` shall
|
| 27 |
+
not appear as *identifier*s in a *module-name* or *module-partition*.
|
| 28 |
+
All *module-name*s either beginning with an *identifier* consisting of
|
| 29 |
+
`std` followed by zero or more *digit*s or containing a reserved
|
| 30 |
+
identifier [[lex.name]] are reserved and shall not be specified in a
|
| 31 |
+
*module-declaration*; no diagnostic is required. If any *identifier* in
|
| 32 |
+
a reserved *module-name* is a reserved identifier, the module name is
|
| 33 |
+
reserved for use by C++ implementations; otherwise it is reserved for
|
| 34 |
+
future standardization. The optional *attribute-specifier-seq*
|
| 35 |
+
appertains to the *module-declaration*.
|
| 36 |
+
|
| 37 |
+
A *module interface unit* is a module unit whose *module-declaration*
|
| 38 |
+
starts with *export-keyword*; any other module unit is a *module
|
| 39 |
+
implementation unit*. A named module shall contain exactly one module
|
| 40 |
+
interface unit with no *module-partition*, known as the *primary module
|
| 41 |
+
interface unit* of the module; no diagnostic is required.
|
| 42 |
+
|
| 43 |
+
A *module partition* is a module unit whose *module-declaration*
|
| 44 |
+
contains a *module-partition*. A named module shall not contain multiple
|
| 45 |
+
module partitions with the same *module-partition*. All module
|
| 46 |
+
partitions of a module that are module interface units shall be directly
|
| 47 |
+
or indirectly exported by the primary module interface unit
|
| 48 |
+
[[module.import]]. No diagnostic is required for a violation of these
|
| 49 |
+
rules.
|
| 50 |
+
|
| 51 |
+
[*Note 1*: Module partitions can be imported only by other module units
|
| 52 |
+
in the same module. The division of a module into module units is not
|
| 53 |
+
visible outside the module. — *end note*]
|
| 54 |
+
|
| 55 |
+
[*Example 1*:
|
| 56 |
+
|
| 57 |
+
Translation unit #1
|
| 58 |
+
|
| 59 |
+
``` cpp
|
| 60 |
+
export module A;
|
| 61 |
+
export import :Foo;
|
| 62 |
+
export int baz();
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
Translation unit #2
|
| 66 |
+
|
| 67 |
+
``` cpp
|
| 68 |
+
export module A:Foo;
|
| 69 |
+
import :Internals;
|
| 70 |
+
export int foo() { return 2 * (bar() + 1); }
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
Translation unit #3
|
| 74 |
+
|
| 75 |
+
``` cpp
|
| 76 |
+
module A:Internals;
|
| 77 |
+
int bar();
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
Translation unit #4
|
| 81 |
+
|
| 82 |
+
``` cpp
|
| 83 |
+
module A;
|
| 84 |
+
import :Internals;
|
| 85 |
+
int bar() { return baz() - 10; }
|
| 86 |
+
int baz() { return 30; }
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
Module `A` contains four translation units:
|
| 90 |
+
|
| 91 |
+
- a primary module interface unit,
|
| 92 |
+
- a module partition `A:Foo`, which is a module interface unit forming
|
| 93 |
+
part of the interface of module `A`,
|
| 94 |
+
- a module partition `A:Internals`, which does not contribute to the
|
| 95 |
+
external interface of module `A`, and
|
| 96 |
+
- a module implementation unit providing a definition of `bar` and
|
| 97 |
+
`baz`, which cannot be imported because it does not have a partition
|
| 98 |
+
name.
|
| 99 |
+
|
| 100 |
+
— *end example*]
|
| 101 |
+
|
| 102 |
+
A *module unit purview* is the sequence of *token*s starting at the
|
| 103 |
+
*module-declaration* and extending to the end of the translation unit.
|
| 104 |
+
The *purview* of a named module `M` is the set of module unit purviews
|
| 105 |
+
of `M`’s module units.
|
| 106 |
+
|
| 107 |
+
The *global module* is the collection of all *global-module-fragment*s
|
| 108 |
+
and all translation units that are not module units. Declarations
|
| 109 |
+
appearing in such a context are said to be in the *purview* of the
|
| 110 |
+
global module.
|
| 111 |
+
|
| 112 |
+
[*Note 2*: The global module has no name, no module interface unit, and
|
| 113 |
+
is not introduced by any *module-declaration*. — *end note*]
|
| 114 |
+
|
| 115 |
+
A *module* is either a named module or the global module. A declaration
|
| 116 |
+
is *attached* to a module as follows:
|
| 117 |
+
|
| 118 |
+
- If the declaration
|
| 119 |
+
- is a replaceable global allocation or deallocation function (
|
| 120 |
+
[[new.delete.single]], [[new.delete.array]]), or
|
| 121 |
+
- is a *namespace-definition* with external linkage, or
|
| 122 |
+
- appears within a *linkage-specification*,
|
| 123 |
+
|
| 124 |
+
it is attached to the global module.
|
| 125 |
+
- Otherwise, the declaration is attached to the module in whose purview
|
| 126 |
+
it appears.
|
| 127 |
+
|
| 128 |
+
A *module-declaration* that contains neither an *export-keyword* nor a
|
| 129 |
+
*module-partition* implicitly imports the primary module interface unit
|
| 130 |
+
of the module as if by a *module-import-declaration*.
|
| 131 |
+
|
| 132 |
+
[*Example 2*:
|
| 133 |
+
|
| 134 |
+
Translation unit #1
|
| 135 |
+
|
| 136 |
+
``` cpp
|
| 137 |
+
module B:Y; // does not implicitly import B
|
| 138 |
+
int y();
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
Translation unit #2
|
| 142 |
+
|
| 143 |
+
``` cpp
|
| 144 |
+
export module B;
|
| 145 |
+
import :Y; // OK, does not create interface dependency cycle
|
| 146 |
+
int n = y();
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
Translation unit #3
|
| 150 |
+
|
| 151 |
+
``` cpp
|
| 152 |
+
module B:X1; // does not implicitly import B
|
| 153 |
+
int &a = n; // error: n not visible here
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
Translation unit #4
|
| 157 |
+
|
| 158 |
+
``` cpp
|
| 159 |
+
module B:X2; // does not implicitly import B
|
| 160 |
+
import B;
|
| 161 |
+
int &b = n; // OK
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
Translation unit #5
|
| 165 |
+
|
| 166 |
+
``` cpp
|
| 167 |
+
module B; // implicitly imports B
|
| 168 |
+
int &c = n; // OK
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
— *end example*]
|
| 172 |
+
|