From Jason Turner

[class.access.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpn80u2cu0/{from.md → to.md} +14 -11
tmp/tmpn80u2cu0/{from.md → to.md} RENAMED
@@ -12,13 +12,13 @@ A member of a class can be
12
  [*Note 1*: A constructor or destructor can be named by an expression
13
  [[basic.def.odr]] even though it has no name. — *end note*]
14
 
15
  A member of a class can also access all the members to which the class
16
  has access. A local class of a member function may access the same
17
- members that the member function itself may access.[^11]
18
 
19
- Members of a class defined with the keyword `class` are `private` by
20
  default. Members of a class defined with the keywords `struct` or
21
  `union` are public by default.
22
 
23
  [*Example 1*:
24
 
@@ -61,14 +61,15 @@ void g(S* sp) {
61
  — *end example*]
62
 
63
  [*Note 3*:
64
 
65
  Because access control applies to the declarations named, if access
66
- control is applied to a *typedef-name*, only the accessibility of the
67
  typedef or alias declaration itself is considered. The accessibility of
68
- the entity referred to by the *typedef-name* is not considered. For
69
- example,
 
70
 
71
  ``` cpp
72
  class A {
73
  class B { };
74
  public:
@@ -79,10 +80,12 @@ void f() {
79
  A::BB x; // OK, typedef A::BB is public
80
  A::B y; // access error, A::B is private
81
  }
82
  ```
83
 
 
 
84
  — *end note*]
85
 
86
  [*Note 4*: Access control does not prevent members from being found by
87
  name lookup or implicit conversions to base classes from being
88
  considered. — *end note*]
@@ -98,26 +101,26 @@ and, if the entity is a class, the definitions of members of the class
98
  appearing outside the class’s *member-specification*.
99
 
100
  [*Note 5*: This access also applies to implicit references to
101
  constructors, conversion functions, and destructors. — *end note*]
102
 
103
- [*Example 3*:
104
 
105
  ``` cpp
106
  class A {
107
  typedef int I; // private member
108
- I f();
109
- friend I g(I);
110
  static I x;
111
  template<int> struct Q;
112
  template<int> friend struct R;
113
  protected:
114
  struct B { };
115
  };
116
 
117
- A::I A::f() { return 0; }
118
- A::I g(A::I p = A::x);
119
  A::I g(A::I p) { return 0; }
120
  A::I A::x = 0;
121
  template<A::I> struct A::Q { };
122
  template<A::I> struct R { };
123
 
@@ -142,11 +145,11 @@ and in member functions of class templates is performed as described in 
142
  [[temp.inst]].
143
 
144
  Access for a default *template-argument* [[temp.param]] is checked in
145
  the context in which it appears rather than at any points of use of it.
146
 
147
- [*Example 4*:
148
 
149
  ``` cpp
150
  class B { };
151
  template <class T> class C {
152
  protected:
 
12
  [*Note 1*: A constructor or destructor can be named by an expression
13
  [[basic.def.odr]] even though it has no name. — *end note*]
14
 
15
  A member of a class can also access all the members to which the class
16
  has access. A local class of a member function may access the same
17
+ members that the member function itself may access.[^9]
18
 
19
+ Members of a class defined with the keyword `class` are private by
20
  default. Members of a class defined with the keywords `struct` or
21
  `union` are public by default.
22
 
23
  [*Example 1*:
24
 
 
61
  — *end example*]
62
 
63
  [*Note 3*:
64
 
65
  Because access control applies to the declarations named, if access
66
+ control is applied to a type alias, only the accessibility of the
67
  typedef or alias declaration itself is considered. The accessibility of
68
+ the underlying entity is not considered.
69
+
70
+ [*Example 3*:
71
 
72
  ``` cpp
73
  class A {
74
  class B { };
75
  public:
 
80
  A::BB x; // OK, typedef A::BB is public
81
  A::B y; // access error, A::B is private
82
  }
83
  ```
84
 
85
+ — *end example*]
86
+
87
  — *end note*]
88
 
89
  [*Note 4*: Access control does not prevent members from being found by
90
  name lookup or implicit conversions to base classes from being
91
  considered. — *end note*]
 
101
  appearing outside the class’s *member-specification*.
102
 
103
  [*Note 5*: This access also applies to implicit references to
104
  constructors, conversion functions, and destructors. — *end note*]
105
 
106
+ [*Example 4*:
107
 
108
  ``` cpp
109
  class A {
110
  typedef int I; // private member
111
+ I f() pre(A::x > 0);
112
+ friend I g(I) post(A::x <= 0);
113
  static I x;
114
  template<int> struct Q;
115
  template<int> friend struct R;
116
  protected:
117
  struct B { };
118
  };
119
 
120
+ A::I A::f() pre(A::x > 0) { return 0; }
121
+ A::I g(A::I p = A::x) post(A::x <= 0);
122
  A::I g(A::I p) { return 0; }
123
  A::I A::x = 0;
124
  template<A::I> struct A::Q { };
125
  template<A::I> struct R { };
126
 
 
145
  [[temp.inst]].
146
 
147
  Access for a default *template-argument* [[temp.param]] is checked in
148
  the context in which it appears rather than at any points of use of it.
149
 
150
+ [*Example 5*:
151
 
152
  ``` cpp
153
  class B { };
154
  template <class T> class C {
155
  protected: