tmp/tmpcckqdnm7/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Private module fragment <a id="module.private.frag">[[module.private.frag]]</a>
|
| 2 |
+
|
| 3 |
+
``` bnf
|
| 4 |
+
private-module-fragment:
|
| 5 |
+
module-keyword ':' private ';' declaration-seqₒₚₜ
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
A *private-module-fragment* shall appear only in a primary module
|
| 9 |
+
interface unit [[module.unit]]. A module unit with a
|
| 10 |
+
*private-module-fragment* shall be the only module unit of its module;
|
| 11 |
+
no diagnostic is required.
|
| 12 |
+
|
| 13 |
+
[*Note 1*:
|
| 14 |
+
|
| 15 |
+
A *private-module-fragment* ends the portion of the module interface
|
| 16 |
+
unit that can affect the behavior of other translation units. A
|
| 17 |
+
*private-module-fragment* allows a module to be represented as a single
|
| 18 |
+
translation unit without making all of the contents of the module
|
| 19 |
+
reachable to importers. The presence of a *private-module-fragment*
|
| 20 |
+
affects:
|
| 21 |
+
|
| 22 |
+
- the point by which the definition of an exported inline function is
|
| 23 |
+
required [[dcl.inline]],
|
| 24 |
+
- the point by which the definition of an exported function with a
|
| 25 |
+
placeholder return type is required [[dcl.spec.auto]],
|
| 26 |
+
- whether a declaration is required not to be an exposure
|
| 27 |
+
[[basic.link]],
|
| 28 |
+
- where definitions for inline functions and templates must appear (
|
| 29 |
+
[[basic.def.odr]], [[dcl.inline]], [[temp.pre]]),
|
| 30 |
+
- the instantiation contexts of templates instantiated before it
|
| 31 |
+
[[module.context]], and
|
| 32 |
+
- the reachability of declarations within it [[module.reach]].
|
| 33 |
+
|
| 34 |
+
— *end note*]
|
| 35 |
+
|
| 36 |
+
[*Example 1*:
|
| 37 |
+
|
| 38 |
+
``` cpp
|
| 39 |
+
export module A;
|
| 40 |
+
export inline void fn_e(); // error: exported inline function fn_e not defined
|
| 41 |
+
// before private module fragment
|
| 42 |
+
inline void fn_m(); // OK, module-linkage inline function
|
| 43 |
+
static void fn_s();
|
| 44 |
+
export struct X;
|
| 45 |
+
export void g(X *x) {
|
| 46 |
+
fn_s(); // OK, call to static function in same translation unit
|
| 47 |
+
fn_m(); // OK, call to module-linkage inline function
|
| 48 |
+
}
|
| 49 |
+
export X *factory(); // OK
|
| 50 |
+
|
| 51 |
+
module :private;
|
| 52 |
+
struct X {}; // definition not reachable from importers of A
|
| 53 |
+
X *factory() {
|
| 54 |
+
return new X ();
|
| 55 |
+
}
|
| 56 |
+
void fn_e() {}
|
| 57 |
+
void fn_m() {}
|
| 58 |
+
void fn_s() {}
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
— *end example*]
|
| 62 |
+
|