[config] A question about BOOST_NO_NESTED_FRIENDSHIP

Hi, I've been merging my recent additions to the release branch and came across the BOOST_NO_NESTED_FRIENDSHIP macro, which hasn't been merged. Looking at its description and test, I'm not certain whether this macro actually flags a compiler deficiency, rather than valid behavior. Here's the description: If the compiler fails to support access to private members from nested classes And the test: class A { static int b; class B { int f() { return b; } }; }; To my understanding, 11.8 says that it shouldn't compile, as B doesn't have any privileged access to A::b. Am I missing something?

It was changed in TC1, and the current draft says: 11.8 Nested classes [class.access.nest] 1 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 ] However, I note that nothing making use of this macro (Borland and Codegear compilers define it), so I don't know what the rationale was for adding it, and annoyingly I can't find the Trac ticket or email that requested it now :-(( John.
participants (2)
-
Andrey Semashev
-
John Maddock