[PATCH] Removing unnecessary friend declarations from kcolordialog.h
Christoph Bartoschek
bartoschek at gmx.de
Sat Oct 4 19:20:10 BST 2008
Am Samstag 04 Oktober 2008 schrieb Christoph Bartoschek:
> Am Samstag 04 Oktober 2008 schrieb Albert Astals Cid:
> > A Dissabte 04 Octubre 2008, Christoph Bartoschek va escriure:
> > > Hi,
> > >
> > > the following patch removes three unnecessary friend declarations from
> > > kcolordialog.h.
> > >
> > > This patch is necessary to compile KDE code with EDG-based compilers.
> > > They choke on the second and third firend declaration, because they
> > > seem to be obviously wrong.
> >
> > I can see the second and third are wrong because they are for classes
> > that don't exist in that scope, but the first?
>
> The first is not wrong. However it is unnecessary. First, this higher
> privileges are not used, as far as I can see it. Second, the revised C++
> standard will give inner classes access to private members of the outer
> classes if I remember correctly.
>
> Maybe it is not yet approved:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2609.html#45
I see in the current working draft that the proposal is incorporated:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2723.pdf
I cite clause 11.8:
A nested class is a member and as such has the same access rights as any
other member. The members of an enclosing class have no special access to
members of a nested class; the usual access rules (Clause 11) shall be
obeyed.
[ Example:
class E {
int x;
class B { };
class I {
B b; // OK: E::I can access E::B
int y;
void f(E* p, int i) {
p->x = i; // OK: E::I can access E::x
}
};
int g(I* p) {
return p->y; // error: I::y is private
}
};
— end example ]
This means that there is no need to make nested classes friend. Although this
is the text of the comming standard any decent compiler should support this
and at least GCC does.
Christoph
More information about the kde-core-devel
mailing list