This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-02-07


1439. Lookup and friend template declarations

Section: _N4868_.9.8.2.3  [namespace.memdef]     Status: CD3     Submitter: Richard Smith     Date: 2012-01-04

[Moved to DR at the October, 2012 meeting.]

According to _N4868_.9.8.2.3 [namespace.memdef] paragraph 3,

If a friend declaration in a non-local class first declares a class or function95 the friend class or function is a member of the innermost enclosing namespace. The name of the friend is not found by unqualified lookup (6.5.3 [basic.lookup.unqual]) or by qualified lookup (6.5.5 [basic.lookup.qual]) until a matching declaration is provided in that namespace scope (either before or after the class definition granting friendship).

This wording does not, but probably should, apply to friend declarations of function templates and class templates as well.

Proposed resolution (February, 2012):

  1. Change 6.5.4 [basic.lookup.argdep] paragraph 1 as follows:

  2. ...in those namespaces, namespace-scope friend function or function template declarations (11.3) not otherwise visible may be found...
  3. Change _N4868_.9.8.2.3 [namespace.memdef] paragraph 3 as follows:

  4. Every name first declared in a namespace is a member of that namespace. If a friend declaration in a non-local class first declares a class, or function, class template, or function template95 the friend class or function is a member of the innermost enclosing namespace. The name of the friend is not found by unqualified lookup (6.5.3 [basic.lookup.unqual]) or by qualified lookup (6.5.5 [basic.lookup.qual]) until a matching declaration is provided in that namespace scope (either before or after the class definition granting friendship). If a friend function or function template is called, its name may be found by the name lookup that considers functions from namespaces and classes associated with the types of the function arguments (6.5.4 [basic.lookup.argdep]). If the name in a friend declaration...