boost_no_nested_friendship.ipp 882 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (C) 2008 N. Musatti
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for most recent version.
  6. // MACRO: BOOST_NO_NESTED_FRIENDSHIP
  7. // TITLE: Access to private members from nested classes
  8. // DESCRIPTION: If the compiler fails to support access to private members
  9. // from nested classes
  10. namespace boost_no_nested_friendship {
  11. class A {
  12. public:
  13. A() {}
  14. struct B {
  15. int f(A& a)
  16. {
  17. a.f1();
  18. a.f2(a);
  19. return a.b;
  20. }
  21. };
  22. private:
  23. static int b;
  24. static void f1(){}
  25. template <class T>
  26. static void f2(const T&){}
  27. };
  28. int A::b = 0;
  29. int test()
  30. {
  31. A a;
  32. A::B b;
  33. return b.f(a);
  34. }
  35. }