Title
Handling of friends in argument-dependent lookup
Status
tentatively ready
Section
6.5.4 [basic.lookup.argdep]
Submitter
Tim Song

Created on 2025-12-18.00:00:00 last changed 4 days ago

Messages

Date: 2026-04-17.22:17:22

Proposed resolution (approved by CWG 2026-04-17):

Change in 6.5.4 [basic.lookup.argdep] bullet 4.2 as follows:

The associated namespaces for a call are the innermost enclosing non-inline namespaces for its associated entities as well as every element of the inline namespace set (9.9.2 [namespace.def]) of those namespaces. Argument-dependent lookup finds all declarations of functions and function templates that
  • are found by a search of any associated namespace, or
  • are declared as a friend (11.8.4 [class.friend]) of any class with a reachable definition in the set of associated entities, where the class has a reachable definition and the friend is declared with an unqualified-id as its declarator-id, or
  • are exported, are attached to a named module M (10.2 [module.interface]), do not appear in the translation unit containing the point of the lookup, and have the same innermost enclosing non-inline namespace scope as a declaration of an associated entity attached to M (6.7 [basic.link]).
Date: 2025-12-18.00:00:00

(From submission #831.)

Consider:

  struct A;
  namespace ns { int f(A&&); }
  struct A {
    friend int ns::f(A&&);
  };

  int x = f(A{});

P1787R6 changed the treatment of this example; see 6.5.4 [basic.lookup.argdep] bullet 4.2.

History
Date User Action Args
2026-04-17 22:17:22adminsetstatus: open -> tentatively ready
2026-04-16 21:12:14adminsetmessages: + msg8532
2025-12-18 00:00:00admincreate