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

2024-03-20


718. Non-class, non-function friend declarations

Section: 11.8.4  [class.friend]     Status: NAD     Submitter: John Spicer     Date: 18 September, 2008     Liaison: EWG

With the change from a scope-based to an entity-based definition of friendship (see issues 372 and 580), it could well make sense to grant friendship to enumerations and variables, for example:

    enum E: int;
    class C {
      static const int i = 5;  // Private
      friend E;
      friend int x;
    };
    enum E { e = C::i; };      // OK: E is a friend
    int x = C::i;              // OK: x is a friend

According to the current wording of 11.8.4 [class.friend] paragraph 3, the friend declaration of E is well-formed but ignored, while the friend declaration of x is ill-formed.

Additional notes (February, 2023)

Forwarding to EWG for review of this extension, per decision of the CWG chair. See cplusplus/papers#1466.

EWG 2023-05-11

This is an extension that needs a well-motivated paper to EWG.