From Jason Turner

[basic.lookup.argdep]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpruvt9eyq/{from.md → to.md} +19 -10
tmp/tmpruvt9eyq/{from.md → to.md} RENAMED
@@ -7,27 +7,30 @@ those namespaces, namespace-scope friend function or function template
7
  declarations ([[class.friend]]) not otherwise visible may be found.
8
  These modifications to the search depend on the types of the arguments
9
  (and for template template arguments, the namespace of the template
10
  argument).
11
 
 
 
12
  ``` cpp
13
  namespace N {
14
  struct S { };
15
  void f(S);
16
  }
17
 
18
  void g() {
19
  N::S s;
20
  f(s); // OK: calls N::f
21
- (f)(s); // error: N::f not considered; parentheses
22
- // prevent argument-dependent lookup
23
  }
24
  ```
25
 
 
 
26
  For each argument type `T` in the function call, there is a set of zero
27
- or more associated namespaces and a set of zero or more associated
28
- classes to be considered. The sets of namespaces and classes is
29
  determined entirely by the types of the function arguments (and the
30
  namespace of any template template argument). Typedef names and
31
  *using-declaration*s used to specify the types do not contribute to this
32
  set. The sets of namespaces and classes are determined in the following
33
  way:
@@ -42,12 +45,12 @@ way:
42
  and classes also include: the namespaces and classes associated with
43
  the types of the template arguments provided for template type
44
  parameters (excluding template template parameters); the namespaces of
45
  which any template template arguments are members; and the classes of
46
  which any member templates used as template template arguments are
47
- members. Non-type template arguments do not contribute to the set of
48
- associated namespaces.
49
  - If `T` is an enumeration type, its associated namespace is the
50
  innermost enclosing namespace of its declaration. If it is a class
51
  member, its associated class is the member’s class; else it has no
52
  associated class.
53
  - If `T` is a pointer to `U` or an array of `U`, its associated
@@ -80,18 +83,22 @@ Let *X* be the lookup set produced by unqualified lookup (
80
  argument dependent lookup (defined as follows). If *X* contains
81
 
82
  - a declaration of a class member, or
83
  - a block-scope function declaration that is not a *using-declaration*,
84
  or
85
- - a declaration that is neither a function or a function template
86
 
87
  then *Y* is empty. Otherwise *Y* is the set of declarations found in the
88
  namespaces associated with the argument types as described below. The
89
  set of declarations found by the lookup of the name is the union of *X*
90
- and *Y*. The namespaces and classes associated with the argument types
91
- can include namespaces and classes already considered by the ordinary
92
- unqualified lookup.
 
 
 
 
93
 
94
  ``` cpp
95
  namespace NS {
96
  class T { };
97
  void f(T);
@@ -104,10 +111,12 @@ int main() {
104
  extern void g(NS::T, float);
105
  g(parm, 1); // OK: calls g(NS::T, float)
106
  }
107
  ```
108
 
 
 
109
  When considering an associated namespace, the lookup is the same as the
110
  lookup performed when the associated namespace is used as a qualifier (
111
  [[namespace.qual]]) except that:
112
 
113
  - Any *using-directive*s in the associated namespace are ignored.
 
7
  declarations ([[class.friend]]) not otherwise visible may be found.
8
  These modifications to the search depend on the types of the arguments
9
  (and for template template arguments, the namespace of the template
10
  argument).
11
 
12
+ [*Example 1*:
13
+
14
  ``` cpp
15
  namespace N {
16
  struct S { };
17
  void f(S);
18
  }
19
 
20
  void g() {
21
  N::S s;
22
  f(s); // OK: calls N::f
23
+ (f)(s); // error: N::f not considered; parentheses prevent argument-dependent lookup
 
24
  }
25
  ```
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
+ classes* to be considered. The sets of namespaces and classes are
32
  determined entirely by the types of the function arguments (and the
33
  namespace of any template template argument). Typedef names and
34
  *using-declaration*s used to specify the types do not contribute to this
35
  set. The sets of namespaces and classes are determined in the following
36
  way:
 
45
  and classes also include: the namespaces and classes associated with
46
  the types of the template arguments provided for template type
47
  parameters (excluding template template parameters); the namespaces of
48
  which any template template arguments are members; and the classes of
49
  which any member templates used as template template arguments are
50
+ members. \[*Note 1*: Non-type template arguments do not contribute to
51
+ the set of associated namespaces. — *end note*]
52
  - If `T` is an enumeration type, its associated namespace is the
53
  innermost enclosing namespace of its declaration. If it is a class
54
  member, its associated class is the member’s class; else it has no
55
  associated class.
56
  - If `T` is a pointer to `U` or an array of `U`, its associated
 
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
88
+ - a declaration that is neither a function nor a function template
89
 
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 classes associated with the argument
96
+ types can include namespaces and classes already considered by the
97
+ ordinary unqualified lookup. — *end note*]
98
+
99
+ [*Example 2*:
100
 
101
  ``` cpp
102
  namespace NS {
103
  class T { };
104
  void f(T);
 
111
  extern void g(NS::T, float);
112
  g(parm, 1); // OK: calls g(NS::T, float)
113
  }
114
  ```
115
 
116
+ — *end example*]
117
+
118
  When considering an associated namespace, the lookup is the same as the
119
  lookup performed when the associated namespace is used as a qualifier (
120
  [[namespace.qual]]) except that:
121
 
122
  - Any *using-directive*s in the associated namespace are ignored.