- tmp/tmpezlu5g1a/{from.md → to.md} +114 -53
tmp/tmpezlu5g1a/{from.md → to.md}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
### Argument-dependent name lookup <a id="basic.lookup.argdep">[[basic.lookup.argdep]]</a>
|
| 2 |
|
| 3 |
-
When the *postfix-expression* in a function call
|
| 4 |
*unqualified-id*, other namespaces not considered during the usual
|
| 5 |
-
unqualified lookup
|
| 6 |
-
|
| 7 |
-
declarations
|
| 8 |
-
|
| 9 |
-
|
| 10 |
argument).
|
| 11 |
|
| 12 |
[*Example 1*:
|
| 13 |
|
| 14 |
``` cpp
|
|
@@ -26,62 +26,62 @@ void g() {
|
|
| 26 |
|
| 27 |
— *end example*]
|
| 28 |
|
| 29 |
For each argument type `T` in the function call, there is a set of zero
|
| 30 |
or more *associated namespaces* and a set of zero or more *associated
|
| 31 |
-
|
| 32 |
-
determined entirely by the types of the
|
| 33 |
-
namespace of any template template
|
| 34 |
-
*using-declaration*s used to specify the
|
| 35 |
-
set. The sets of namespaces and
|
| 36 |
-
way:
|
| 37 |
|
| 38 |
- If `T` is a fundamental type, its associated sets of namespaces and
|
| 39 |
-
|
| 40 |
-
- If `T` is a class type (including unions), its associated
|
| 41 |
-
the class itself; the class of which it is a member, if any; and
|
| 42 |
-
direct and indirect base classes. Its associated namespaces are
|
| 43 |
-
innermost enclosing namespaces of its associated
|
| 44 |
-
if `T` is a class template specialization, its associated
|
| 45 |
-
and
|
| 46 |
-
the types of the template arguments provided for
|
| 47 |
-
parameters (excluding template template parameters); the
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 52 |
- If `T` is an enumeration type, its associated namespace is the
|
| 53 |
-
innermost enclosing namespace of its declaration
|
| 54 |
-
|
| 55 |
-
associated class.
|
| 56 |
- If `T` is a pointer to `U` or an array of `U`, its associated
|
| 57 |
-
namespaces and
|
| 58 |
-
- If `T` is a function type, its associated namespaces and
|
| 59 |
those associated with the function parameter types and those
|
| 60 |
associated with the return type.
|
| 61 |
- If `T` is a pointer to a member function of a class `X`, its
|
| 62 |
-
associated namespaces and
|
| 63 |
function parameter types and return type, together with those
|
| 64 |
associated with `X`.
|
| 65 |
- If `T` is a pointer to a data member of class `X`, its associated
|
| 66 |
-
namespaces and
|
| 67 |
together with those associated with `X`.
|
| 68 |
|
| 69 |
-
If an associated namespace is an inline namespace
|
| 70 |
-
|
| 71 |
namespace directly contains inline namespaces, those inline namespaces
|
| 72 |
are also included in the set. In addition, if the argument is the name
|
| 73 |
-
or address of
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
*template-
|
| 79 |
-
|
| 80 |
|
| 81 |
-
Let *X* be the lookup set produced by unqualified lookup
|
| 82 |
-
[[basic.lookup.unqual]]
|
| 83 |
argument dependent lookup (defined as follows). If *X* contains
|
| 84 |
|
| 85 |
- a declaration of a class member, or
|
| 86 |
- a block-scope function declaration that is not a *using-declaration*,
|
| 87 |
or
|
|
@@ -90,12 +90,12 @@ argument dependent lookup (defined as follows). If *X* contains
|
|
| 90 |
then *Y* is empty. Otherwise *Y* is the set of declarations found in the
|
| 91 |
namespaces associated with the argument types as described below. The
|
| 92 |
set of declarations found by the lookup of the name is the union of *X*
|
| 93 |
and *Y*.
|
| 94 |
|
| 95 |
-
[*Note 2*: The namespaces and
|
| 96 |
-
types can include namespaces and
|
| 97 |
ordinary unqualified lookup. — *end note*]
|
| 98 |
|
| 99 |
[*Example 2*:
|
| 100 |
|
| 101 |
``` cpp
|
|
@@ -113,17 +113,78 @@ int main() {
|
|
| 113 |
}
|
| 114 |
```
|
| 115 |
|
| 116 |
— *end example*]
|
| 117 |
|
| 118 |
-
When considering an associated namespace, the lookup is the same as
|
| 119 |
-
lookup performed when
|
| 120 |
-
|
| 121 |
|
| 122 |
-
- Any *using-directive*s in
|
| 123 |
-
- Any namespace-scope friend functions or friend function templates
|
| 124 |
-
declared in associated classes are visible within their respective
|
| 125 |
-
namespaces even if they are not visible during an ordinary lookup (
|
| 126 |
-
[[class.friend]]).
|
| 127 |
- All names except those of (possibly overloaded) functions and function
|
| 128 |
templates are ignored.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
|
|
|
| 1 |
### Argument-dependent name lookup <a id="basic.lookup.argdep">[[basic.lookup.argdep]]</a>
|
| 2 |
|
| 3 |
+
When the *postfix-expression* in a function call [[expr.call]] is an
|
| 4 |
*unqualified-id*, other namespaces not considered during the usual
|
| 5 |
+
unqualified lookup [[basic.lookup.unqual]] may be searched, and in those
|
| 6 |
+
namespaces, namespace-scope friend function or function template
|
| 7 |
+
declarations [[class.friend]] not otherwise visible may be found. These
|
| 8 |
+
modifications to the search depend on the types of the arguments (and
|
| 9 |
+
for template template arguments, the namespace of the template
|
| 10 |
argument).
|
| 11 |
|
| 12 |
[*Example 1*:
|
| 13 |
|
| 14 |
``` cpp
|
|
|
|
| 26 |
|
| 27 |
— *end example*]
|
| 28 |
|
| 29 |
For each argument type `T` in the function call, there is a set of zero
|
| 30 |
or more *associated namespaces* and a set of zero or more *associated
|
| 31 |
+
entities* (other than namespaces) to be considered. The sets of
|
| 32 |
+
namespaces and entities are determined entirely by the types of the
|
| 33 |
+
function arguments (and the namespace of any template template
|
| 34 |
+
argument). Typedef names and *using-declaration*s used to specify the
|
| 35 |
+
types do not contribute to this set. The sets of namespaces and entities
|
| 36 |
+
are determined in the following way:
|
| 37 |
|
| 38 |
- If `T` is a fundamental type, its associated sets of namespaces and
|
| 39 |
+
entities are both empty.
|
| 40 |
+
- If `T` is a class type (including unions), its associated entities
|
| 41 |
+
are: the class itself; the class of which it is a member, if any; and
|
| 42 |
+
its direct and indirect base classes. Its associated namespaces are
|
| 43 |
+
the innermost enclosing namespaces of its associated entities.
|
| 44 |
+
Furthermore, if `T` is a class template specialization, its associated
|
| 45 |
+
namespaces and entities also include: the namespaces and entities
|
| 46 |
+
associated with the types of the template arguments provided for
|
| 47 |
+
template type parameters (excluding template template parameters); the
|
| 48 |
+
templates used as template template arguments; the namespaces of which
|
| 49 |
+
any template template arguments are members; and the classes of which
|
| 50 |
+
any member templates used as template template arguments are members.
|
| 51 |
+
\[*Note 1*: Non-type template arguments do not contribute to the set
|
| 52 |
+
of associated namespaces. — *end note*]
|
| 53 |
- If `T` is an enumeration type, its associated namespace is the
|
| 54 |
+
innermost enclosing namespace of its declaration, and its associated
|
| 55 |
+
entities are `T` and, if it is a class member, the member’s class.
|
|
|
|
| 56 |
- If `T` is a pointer to `U` or an array of `U`, its associated
|
| 57 |
+
namespaces and entities are those associated with `U`.
|
| 58 |
+
- If `T` is a function type, its associated namespaces and entities are
|
| 59 |
those associated with the function parameter types and those
|
| 60 |
associated with the return type.
|
| 61 |
- If `T` is a pointer to a member function of a class `X`, its
|
| 62 |
+
associated namespaces and entities are those associated with the
|
| 63 |
function parameter types and return type, together with those
|
| 64 |
associated with `X`.
|
| 65 |
- If `T` is a pointer to a data member of class `X`, its associated
|
| 66 |
+
namespaces and entities are those associated with the member type
|
| 67 |
together with those associated with `X`.
|
| 68 |
|
| 69 |
+
If an associated namespace is an inline namespace [[namespace.def]], its
|
| 70 |
+
enclosing namespace is also included in the set. If an associated
|
| 71 |
namespace directly contains inline namespaces, those inline namespaces
|
| 72 |
are also included in the set. In addition, if the argument is the name
|
| 73 |
+
or address of an overload set, its associated entities and namespaces
|
| 74 |
+
are the union of those associated with each of the members of the set,
|
| 75 |
+
i.e., the entities and namespaces associated with its parameter types
|
| 76 |
+
and return type. Additionally, if the aforementioned overload set is
|
| 77 |
+
named with a *template-id*, its associated entities and namespaces also
|
| 78 |
+
include those of its type *template-argument*s and its template
|
| 79 |
+
*template-argument*s.
|
| 80 |
|
| 81 |
+
Let *X* be the lookup set produced by unqualified lookup
|
| 82 |
+
[[basic.lookup.unqual]] and let *Y* be the lookup set produced by
|
| 83 |
argument dependent lookup (defined as follows). If *X* contains
|
| 84 |
|
| 85 |
- a declaration of a class member, or
|
| 86 |
- a block-scope function declaration that is not a *using-declaration*,
|
| 87 |
or
|
|
|
|
| 90 |
then *Y* is empty. Otherwise *Y* is the set of declarations found in the
|
| 91 |
namespaces associated with the argument types as described below. The
|
| 92 |
set of declarations found by the lookup of the name is the union of *X*
|
| 93 |
and *Y*.
|
| 94 |
|
| 95 |
+
[*Note 2*: The namespaces and entities associated with the argument
|
| 96 |
+
types can include namespaces and entities already considered by the
|
| 97 |
ordinary unqualified lookup. — *end note*]
|
| 98 |
|
| 99 |
[*Example 2*:
|
| 100 |
|
| 101 |
``` cpp
|
|
|
|
| 113 |
}
|
| 114 |
```
|
| 115 |
|
| 116 |
— *end example*]
|
| 117 |
|
| 118 |
+
When considering an associated namespace `N`, the lookup is the same as
|
| 119 |
+
the lookup performed when `N` is used as a qualifier [[namespace.qual]]
|
| 120 |
+
except that:
|
| 121 |
|
| 122 |
+
- Any *using-directive*s in `N` are ignored.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
- All names except those of (possibly overloaded) functions and function
|
| 124 |
templates are ignored.
|
| 125 |
+
- Any namespace-scope friend functions or friend function templates
|
| 126 |
+
[[class.friend]] declared in classes with reachable definitions in the
|
| 127 |
+
set of associated entities are visible within their respective
|
| 128 |
+
namespaces even if they are not visible during an ordinary lookup
|
| 129 |
+
[[namespace.memdef]].
|
| 130 |
+
- Any exported declaration `D` in `N` declared within the purview of a
|
| 131 |
+
named module `M` [[module.interface]] is visible if there is an
|
| 132 |
+
associated entity attached to `M` with the same innermost enclosing
|
| 133 |
+
non-inline namespace as `D`.
|
| 134 |
+
- If the lookup is for a dependent name ([[temp.dep]],
|
| 135 |
+
[[temp.dep.candidate]]), any declaration `D` in `N` is visible if `D`
|
| 136 |
+
would be visible to qualified name lookup [[namespace.qual]] at any
|
| 137 |
+
point in the instantiation context [[module.context]] of the lookup,
|
| 138 |
+
unless `D` is declared in another translation unit, attached to the
|
| 139 |
+
global module, and is either discarded [[module.global.frag]] or has
|
| 140 |
+
internal linkage.
|
| 141 |
+
|
| 142 |
+
[*Example 3*:
|
| 143 |
+
|
| 144 |
+
Translation unit #1
|
| 145 |
+
|
| 146 |
+
``` cpp
|
| 147 |
+
export module M;
|
| 148 |
+
namespace R {
|
| 149 |
+
export struct X {};
|
| 150 |
+
export void f(X);
|
| 151 |
+
}
|
| 152 |
+
namespace S {
|
| 153 |
+
export void f(R::X, R::X);
|
| 154 |
+
}
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
Translation unit #2
|
| 158 |
+
|
| 159 |
+
``` cpp
|
| 160 |
+
export module N;
|
| 161 |
+
import M;
|
| 162 |
+
export R::X make();
|
| 163 |
+
namespace R { static int g(X); }
|
| 164 |
+
export template<typename T, typename U> void apply(T t, U u) {
|
| 165 |
+
f(t, u);
|
| 166 |
+
g(t);
|
| 167 |
+
}
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
Translation unit #3
|
| 171 |
+
|
| 172 |
+
``` cpp
|
| 173 |
+
module Q;
|
| 174 |
+
import N;
|
| 175 |
+
namespace S {
|
| 176 |
+
struct Z { template<typename T> operator T(); };
|
| 177 |
+
}
|
| 178 |
+
void test() {
|
| 179 |
+
auto x = make(); // OK, decltype(x) is R::X in module M
|
| 180 |
+
R::f(x); // error: R and R::f are not visible here
|
| 181 |
+
f(x); // OK, calls R::f from interface of M
|
| 182 |
+
f(x, S::Z()); // error: S::f in module M not considered
|
| 183 |
+
// even though S is an associated namespace
|
| 184 |
+
apply(x, S::Z()); // error: S::f is visible in instantiation context, but
|
| 185 |
+
// R::g has internal linkage and cannot be used outside TU #2
|
| 186 |
+
}
|
| 187 |
+
```
|
| 188 |
+
|
| 189 |
+
— *end example*]
|
| 190 |
|