tmp/tmpda_nenzs/{from.md → to.md}
RENAMED
|
@@ -4,12 +4,12 @@ The declarative region of a *namespace-definition* is its
|
|
| 4 |
*namespace-body*. Entities declared in a *namespace-body* are said to be
|
| 5 |
*members* of the namespace, and names introduced by these declarations
|
| 6 |
into the declarative region of the namespace are said to be *member
|
| 7 |
names* of the namespace. A namespace member name has namespace scope.
|
| 8 |
Its potential scope includes its namespace from the name’s point of
|
| 9 |
-
declaration
|
| 10 |
-
*using-directive*
|
| 11 |
namespace, the member’s potential scope includes that portion of the
|
| 12 |
potential scope of the *using-directive* that follows the member’s point
|
| 13 |
of declaration.
|
| 14 |
|
| 15 |
[*Example 1*:
|
|
@@ -39,18 +39,62 @@ namespace N {
|
|
| 39 |
}
|
| 40 |
```
|
| 41 |
|
| 42 |
— *end example*]
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
A namespace member can also be referred to after the `::` scope
|
| 45 |
-
resolution operator
|
| 46 |
namespace or the name of a namespace which nominates the member’s
|
| 47 |
namespace in a *using-directive*; see [[namespace.qual]].
|
| 48 |
|
| 49 |
The outermost declarative region of a translation unit is also a
|
| 50 |
namespace, called the *global namespace*. A name declared in the global
|
| 51 |
namespace has *global namespace scope* (also called *global scope*). The
|
| 52 |
-
potential scope of such a name begins at its point of declaration
|
| 53 |
-
[[basic.scope.pdecl]]
|
| 54 |
is its declarative region. A name with global namespace scope is said to
|
| 55 |
be a *global name*.
|
| 56 |
|
|
|
|
| 4 |
*namespace-body*. Entities declared in a *namespace-body* are said to be
|
| 5 |
*members* of the namespace, and names introduced by these declarations
|
| 6 |
into the declarative region of the namespace are said to be *member
|
| 7 |
names* of the namespace. A namespace member name has namespace scope.
|
| 8 |
Its potential scope includes its namespace from the name’s point of
|
| 9 |
+
declaration [[basic.scope.pdecl]] onwards; and for each
|
| 10 |
+
*using-directive* [[namespace.udir]] that nominates the member’s
|
| 11 |
namespace, the member’s potential scope includes that portion of the
|
| 12 |
potential scope of the *using-directive* that follows the member’s point
|
| 13 |
of declaration.
|
| 14 |
|
| 15 |
[*Example 1*:
|
|
|
|
| 39 |
}
|
| 40 |
```
|
| 41 |
|
| 42 |
— *end example*]
|
| 43 |
|
| 44 |
+
If a translation unit Q is imported into a translation unit R
|
| 45 |
+
[[module.import]], the potential scope of a name X declared with
|
| 46 |
+
namespace scope in Q is extended to include the portion of the
|
| 47 |
+
corresponding namespace scope in R following the first
|
| 48 |
+
*module-import-declaration* or *module-declaration* in R that imports Q
|
| 49 |
+
(directly or indirectly) if
|
| 50 |
+
|
| 51 |
+
- X does not have internal linkage, and
|
| 52 |
+
- X is declared after the *module-declaration* in Q (if any), and
|
| 53 |
+
- either X is exported or Q and R are part of the same module.
|
| 54 |
+
|
| 55 |
+
[*Note 1*:
|
| 56 |
+
|
| 57 |
+
A *module-import-declaration* imports both the named translation unit(s)
|
| 58 |
+
and any modules named by exported *module-import-declaration*s within
|
| 59 |
+
them, recursively.
|
| 60 |
+
|
| 61 |
+
[*Example 2*:
|
| 62 |
+
|
| 63 |
+
Translation unit #1
|
| 64 |
+
|
| 65 |
+
``` cpp
|
| 66 |
+
export module Q;
|
| 67 |
+
export int sq(int i) { return i*i; }
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
Translation unit #2
|
| 71 |
+
|
| 72 |
+
``` cpp
|
| 73 |
+
export module R;
|
| 74 |
+
export import Q;
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
Translation unit #3
|
| 78 |
+
|
| 79 |
+
``` cpp
|
| 80 |
+
import R;
|
| 81 |
+
int main() { return sq(9); } // OK: sq from module Q
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
— *end example*]
|
| 85 |
+
|
| 86 |
+
— *end note*]
|
| 87 |
+
|
| 88 |
A namespace member can also be referred to after the `::` scope
|
| 89 |
+
resolution operator [[expr.prim.id.qual]] applied to the name of its
|
| 90 |
namespace or the name of a namespace which nominates the member’s
|
| 91 |
namespace in a *using-directive*; see [[namespace.qual]].
|
| 92 |
|
| 93 |
The outermost declarative region of a translation unit is also a
|
| 94 |
namespace, called the *global namespace*. A name declared in the global
|
| 95 |
namespace has *global namespace scope* (also called *global scope*). The
|
| 96 |
+
potential scope of such a name begins at its point of declaration
|
| 97 |
+
[[basic.scope.pdecl]] and ends at the end of the translation unit that
|
| 98 |
is its declarative region. A name with global namespace scope is said to
|
| 99 |
be a *global name*.
|
| 100 |
|