Title
Non-class, non-function friend declarations
Status
nad
Section
11.8.4 [class.friend]
Submitter
John Spicer

Created on 2008-09-18.00:00:00 last changed 10 months ago

Messages

Date: 2023-02-15.00:00:00

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.

Date: 2008-09-18.00:00:00

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.

History
Date User Action Args
2023-05-11 19:49:32adminsetstatus: open -> nad
2023-02-12 17:47:41adminsetmessages: + msg7199
2008-09-18 00:00:00admincreate