Title
Opaque enumeration friend declarations
Status
nad
Section
11.8.4 [class.friend]
Submitter
Mike Miller

Created on 2017-10-26.00:00:00 last changed 47 months ago

Messages

Date: 2018-10-15.00:00:00

Notes from the October, 2018 teleconference:

The suggested plausible use for the feature would require additional wording, because the effect of friendship is currently only described for classes and functions, not for enumerations. There does not appear to be a demand for the change.

Date: 2017-10-26.00:00:00

According to 11.8.4 [class.friend] paragraph 3,

A friend declaration that does not declare a function shall have one of the following forms:

    friend elaborated-type-specifier ;
    friend simple-type-specifier ;
    friend typename-specifier ;

However, many implementations accept

  friend enum E;

even though that form is explicitly not allowed by 9.2.9.5 [dcl.type.elab] paragraph 1 (which only permits class-key and not enum-key in friend declarations). Some implementations also accept opaque enumeration declarations like

  friend enum E : int;

The latter form could plausibly be used in an example like:

  class C {
    constexpr static int priv = 15;
    friend enum class my_constants;
  };
  enum class my_constants {
    pub = C::priv;                // OK because of friend decl
  };

(See also issue 2131.)

History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6308
2020-12-15 00:00:00adminsetstatus: open -> nad
2017-10-26 00:00:00admincreate