From Jason Turner

[basic.lookup]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpd3zc9o6f/{from.md → to.md} +23 -22
tmp/tmpd3zc9o6f/{from.md → to.md} RENAMED
@@ -98,12 +98,13 @@ void A::N::f() {
98
  // 4) global scope, before the definition of A::N::f
99
  }
100
  ```
101
 
102
  A name used in the definition of a class `X` outside of a member
103
- function body or nested class definition[^5] shall be declared in one of
104
- the following ways:
 
105
 
106
  - before its use in class `X` or be a member of a base class of `X` (
107
  [[class.member.lookup]]), or
108
  - if `X` is a nested class of class `Y` ([[class.nest]]), before the
109
  definition of `X` in `Y`, or shall be a member of a base class of `Y`
@@ -148,15 +149,16 @@ namespace scope are not considered; see  [[namespace.memdef]].
148
  names in a class definition. [[class.nest]] further describes the
149
  restrictions on the use of names in nested class definitions.
150
  [[class.local]] further describes the restrictions on the use of names
151
  in local class definitions.
152
 
153
- A name used in the definition of a member function ([[class.mfct]]) of
154
- class `X` following the function’s *declarator-id*[^7] or in the
155
  *brace-or-equal-initializer* of a non-static data member (
156
- [[class.mem]]) of class `X` shall be declared in one of the following
157
- ways:
 
158
 
159
  - before its use in the block in which it is used or in an enclosing
160
  block ([[stmt.block]]), or
161
  - shall be a member of class `X` or be a member of a base class of `X` (
162
  [[class.member.lookup]]), or
@@ -283,14 +285,14 @@ The rules for name lookup in template definitions are described in 
283
  ### Argument-dependent name lookup <a id="basic.lookup.argdep">[[basic.lookup.argdep]]</a>
284
 
285
  When the *postfix-expression* in a function call ([[expr.call]]) is an
286
  *unqualified-id*, other namespaces not considered during the usual
287
  unqualified lookup ([[basic.lookup.unqual]]) may be searched, and in
288
- those namespaces, namespace-scope friend function declarations (
289
- [[class.friend]]) not otherwise visible may be found. These
290
- modifications to the search depend on the types of the arguments (and
291
- for template template arguments, the namespace of the template
292
  argument).
293
 
294
  ``` cpp
295
  namespace N {
296
  struct S { };
@@ -317,23 +319,23 @@ way:
317
  - If `T` is a fundamental type, its associated sets of namespaces and
318
  classes are both empty.
319
  - If `T` is a class type (including unions), its associated classes are:
320
  the class itself; the class of which it is a member, if any; and its
321
  direct and indirect base classes. Its associated namespaces are the
322
- namespaces of which its associated classes are members. Furthermore,
323
  if `T` is a class template specialization, its associated namespaces
324
  and classes also include: the namespaces and classes associated with
325
  the types of the template arguments provided for template type
326
  parameters (excluding template template parameters); the namespaces of
327
  which any template template arguments are members; and the classes of
328
  which any member templates used as template template arguments are
329
  members. Non-type template arguments do not contribute to the set of
330
  associated namespaces.
331
  - If `T` is an enumeration type, its associated namespace is the
332
- namespace in which it is defined. If it is class member, its
333
- associated class is the member’s class; else it has no associated
334
- class.
335
  - If `T` is a pointer to `U` or an array of `U`, its associated
336
  namespaces and classes are those associated with `U`.
337
  - If `T` is a function type, its associated namespaces and classes are
338
  those associated with the function parameter types and those
339
  associated with the return type.
@@ -510,12 +512,12 @@ lookup rule above are the following:
510
  the context in which the entire *postfix-expression* occurs.
511
  - the lookup for a name specified in a *using-declaration* (
512
  [[namespace.udecl]]) also finds class or enumeration names hidden
513
  within the same scope ([[basic.scope.hiding]]).
514
 
515
- In a lookup in which the constructor is an acceptable lookup result and
516
- the *nested-name-specifier* nominates a class `C`:
517
 
518
  - if the name specified after the *nested-name-specifier*, when looked
519
  up in `C`, is the injected-class-name of `C` (Clause  [[class]]), or
520
  - in a *using-declaration* ([[namespace.udecl]]) that is a
521
  *member-declaration*, if the name specified after the
@@ -851,16 +853,15 @@ If the *id-expression* in a class member access ([[expr.ref]]) is an
851
  *unqualified-id*, and the type of the object expression is of a class
852
  type `C`, the *unqualified-id* is looked up in the scope of class `C`.
853
  For a pseudo-destructor call ([[expr.pseudo]]), the *unqualified-id* is
854
  looked up in the context of the complete *postfix-expression*.
855
 
856
- If the *unqualified-id* is *\textasciitilde{}type-name*, the *type-name*
857
- is looked up in the context of the entire *postfix-expression*. If the
858
- type `T` of the object expression is of a class type `C`, the
859
- *type-name* is also looked up in the scope of class `C`. At least one of
860
- the lookups shall find a name that refers to (possibly cv-qualified)
861
- `T`.
862
 
863
  ``` cpp
864
  struct A { };
865
 
866
  struct B {
 
98
  // 4) global scope, before the definition of A::N::f
99
  }
100
  ```
101
 
102
  A name used in the definition of a class `X` outside of a member
103
+ function body, default argument, *exception-specification*,
104
+ *brace-or-equal-initializer* of a non-static data member, or nested
105
+ class definition[^5] shall be declared in one of the following ways:
106
 
107
  - before its use in class `X` or be a member of a base class of `X` (
108
  [[class.member.lookup]]), or
109
  - if `X` is a nested class of class `Y` ([[class.nest]]), before the
110
  definition of `X` in `Y`, or shall be a member of a base class of `Y`
 
149
  names in a class definition. [[class.nest]] further describes the
150
  restrictions on the use of names in nested class definitions.
151
  [[class.local]] further describes the restrictions on the use of names
152
  in local class definitions.
153
 
154
+ For the members of a class `X`, a name used in a member function body,
155
+ in a default argument, in an *exception-specification*, in the
156
  *brace-or-equal-initializer* of a non-static data member (
157
+ [[class.mem]]), or in the definition of a class member outside of the
158
+ definition of `X`, following the member’s *declarator-id*[^7], shall be
159
+ declared in one of the following ways:
160
 
161
  - before its use in the block in which it is used or in an enclosing
162
  block ([[stmt.block]]), or
163
  - shall be a member of class `X` or be a member of a base class of `X` (
164
  [[class.member.lookup]]), or
 
285
  ### Argument-dependent name lookup <a id="basic.lookup.argdep">[[basic.lookup.argdep]]</a>
286
 
287
  When the *postfix-expression* in a function call ([[expr.call]]) is an
288
  *unqualified-id*, other namespaces not considered during the usual
289
  unqualified lookup ([[basic.lookup.unqual]]) may be searched, and in
290
+ those namespaces, namespace-scope friend function or function template
291
+ declarations ([[class.friend]]) not otherwise visible may be found.
292
+ These modifications to the search depend on the types of the arguments
293
+ (and for template template arguments, the namespace of the template
294
  argument).
295
 
296
  ``` cpp
297
  namespace N {
298
  struct S { };
 
319
  - If `T` is a fundamental type, its associated sets of namespaces and
320
  classes are both empty.
321
  - If `T` is a class type (including unions), its associated classes are:
322
  the class itself; the class of which it is a member, if any; and its
323
  direct and indirect base classes. Its associated namespaces are the
324
+ innermost enclosing namespaces of its associated classes. Furthermore,
325
  if `T` is a class template specialization, its associated namespaces
326
  and classes also include: the namespaces and classes associated with
327
  the types of the template arguments provided for template type
328
  parameters (excluding template template parameters); the namespaces of
329
  which any template template arguments are members; and the classes of
330
  which any member templates used as template template arguments are
331
  members. Non-type template arguments do not contribute to the set of
332
  associated namespaces.
333
  - If `T` is an enumeration type, its associated namespace is the
334
+ innermost enclosing namespace of its declaration. If it is a class
335
+ member, its associated class is the member’s class; else it has no
336
+ associated class.
337
  - If `T` is a pointer to `U` or an array of `U`, its associated
338
  namespaces and classes are those associated with `U`.
339
  - If `T` is a function type, its associated namespaces and classes are
340
  those associated with the function parameter types and those
341
  associated with the return type.
 
512
  the context in which the entire *postfix-expression* occurs.
513
  - the lookup for a name specified in a *using-declaration* (
514
  [[namespace.udecl]]) also finds class or enumeration names hidden
515
  within the same scope ([[basic.scope.hiding]]).
516
 
517
+ In a lookup in which function names are not ignored[^9] and the
518
+ *nested-name-specifier* nominates a class `C`:
519
 
520
  - if the name specified after the *nested-name-specifier*, when looked
521
  up in `C`, is the injected-class-name of `C` (Clause  [[class]]), or
522
  - in a *using-declaration* ([[namespace.udecl]]) that is a
523
  *member-declaration*, if the name specified after the
 
853
  *unqualified-id*, and the type of the object expression is of a class
854
  type `C`, the *unqualified-id* is looked up in the scope of class `C`.
855
  For a pseudo-destructor call ([[expr.pseudo]]), the *unqualified-id* is
856
  looked up in the context of the complete *postfix-expression*.
857
 
858
+ If the *unqualified-id* is `~`*type-name*, the *type-name* is looked up
859
+ in the context of the entire *postfix-expression*. If the type `T` of
860
+ the object expression is of a class type `C`, the *type-name* is also
861
+ looked up in the scope of class `C`. At least one of the lookups shall
862
+ find a name that refers to (possibly cv-qualified) `T`.
 
863
 
864
  ``` cpp
865
  struct A { };
866
 
867
  struct B {