From Jason Turner

[class.protected]

Diff to HTML by rtfpessoa

tmp/tmpg4aj72mt/{from.md → to.md} RENAMED
@@ -1,11 +1,11 @@
1
  ### Protected member access <a id="class.protected">[[class.protected]]</a>
2
 
3
  An additional access check beyond those described earlier in
4
  [[class.access]] is applied when a non-static data member or non-static
5
- member function is a protected member of its naming class
6
- [[class.access.base]].[^13]
7
 
8
  As described earlier, access to a protected member is granted because
9
  the reference occurs in a friend or direct member of some class `C`. If
10
  the access is to form a pointer to member [[expr.unary.op]], the
11
  *nested-name-specifier* shall denote `C` or a class derived from `C`.
@@ -32,14 +32,14 @@ class D2 : public B {
32
 
33
  void fr(B* pb, D1* p1, D2* p2) {
34
  pb->i = 1; // error
35
  p1->i = 2; // error
36
  p2->i = 3; // OK (access through a D2)
37
- p2->B::i = 4; // OK (access through a D2, even though naming class is B)
38
  int B::* pmi_B = &B::i; // error
39
  int B::* pmi_B2 = &D2::i; // OK (type of &D2::i is int B::*)
40
- B::j = 5; // error: not a friend of naming class B
41
  D2::j = 6; // OK (because refers to static member)
42
  }
43
 
44
  void D2::mem(B* pb, D1* p1) {
45
  pb->i = 1; // error
 
1
  ### Protected member access <a id="class.protected">[[class.protected]]</a>
2
 
3
  An additional access check beyond those described earlier in
4
  [[class.access]] is applied when a non-static data member or non-static
5
+ member function is a protected member of its designating class
6
+ [[class.access.base]].[^11]
7
 
8
  As described earlier, access to a protected member is granted because
9
  the reference occurs in a friend or direct member of some class `C`. If
10
  the access is to form a pointer to member [[expr.unary.op]], the
11
  *nested-name-specifier* shall denote `C` or a class derived from `C`.
 
32
 
33
  void fr(B* pb, D1* p1, D2* p2) {
34
  pb->i = 1; // error
35
  p1->i = 2; // error
36
  p2->i = 3; // OK (access through a D2)
37
+ p2->B::i = 4; // OK (access through a D2, even though designating class is B)
38
  int B::* pmi_B = &B::i; // error
39
  int B::* pmi_B2 = &D2::i; // OK (type of &D2::i is int B::*)
40
+ B::j = 5; // error: not a friend of designating class B
41
  D2::j = 6; // OK (because refers to static member)
42
  }
43
 
44
  void D2::mem(B* pb, D1* p1) {
45
  pb->i = 1; // error