Created on 2014-04-27.00:00:00 last changed 23 months ago
Additional note (January, 2024)
The example is ill-formed per the resolution of issue 1862 (adopted in November, 2017).
It is not clear what should happen for an example like:
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; }
};
};
It appears that the friend template matches Q::C, because that class is also A<int>::B::C, but neither GCC nor EDG allow this code (saying X::x is inaccessible). (Clang doesn't support friend template declarations with a dependent scope.)
A strict reading of 13.7.5 [temp.friend] paragraph 5 might suggest that the friend declaration itself is ill-formed, because it does not declare a member of a class template, but I can't find any compiler that implements template friends that way.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2024-01-13 12:51:15 | admin | set | messages: + msg7568 |
| 2024-01-13 12:51:15 | admin | set | status: open -> cd5 |
| 2014-04-27 00:00:00 | admin | create | |