Title
Friend declarations naming members of class templates in non-templates
Status
cd5
Section
13.7.5 [temp.friend]
Submitter
Richard Smith

Created on 2014-06-19.00:00:00 last changed 2 months ago

Messages

Date: 2024-01-15.00:00:00

Additional note (January, 2024)

The example is ill-formed per the resolution of issue 1862 (adopted in November, 2017).

Date: 2014-06-19.00:00:00

During the discussion of issue 1918, it was decided that the last part of the issue should be split off into a separate issue. According to 13.7.5 [temp.friend] paragraph 5,

A member of a class template may be declared to be a friend of a non-template class.

Does this make the example from issue 1918,

  template<typename T> struct A {
    class B {
      class C {};
    };
  };
  class X {
    static int x;
    template <typename T> friend class A<T>::B::C;
  };
  template<> struct A<int> {
    typedef struct Q B;
  };
  struct Q {
    class C {
      int f() { return X::x; }
    };
  };

ill-formed because the friend declaration does not refer to a member of a class template? This does not appear to be the interpretation chosen by most implementations.

History
Date User Action Args
2024-01-13 12:51:15adminsetmessages: + msg7569
2024-01-13 12:51:15adminsetstatus: open -> cd5
2014-06-19 00:00:00admincreate