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

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

Messages

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
2008-09-18 00:00:00admincreate