Skip to content

Commit d89742d

Browse files
jensmaurerzygoloid
authored andcommitted
P1289R1 Access control in contract conditions
1 parent 4a9ad86 commit d89742d

File tree

1 file changed

+0
-46
lines changed

1 file changed

+0
-46
lines changed

source/declarations.tex

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8348,52 +8348,6 @@
83488348
The predicate of a contract condition has the same semantic restrictions
83498349
as if it appeared as the first \grammarterm{expression-statement}
83508350
in the body of the function it applies to.
8351-
Additional access restrictions apply to names appearing in
8352-
a contract condition of a member function of class \tcode{C}:
8353-
\begin{itemize}
8354-
\item Friendship is not considered\iref{class.friend}.
8355-
\item For a contract condition of a public member function,
8356-
no member of \tcode{C} or of an enclosing class of \tcode{C} is accessible
8357-
unless it is a public member of \tcode{C},
8358-
or a member of a base class
8359-
accessible as a public member of \tcode{C}\iref{class.access.base}.
8360-
\item For a contract condition of a protected member function,
8361-
no member of \tcode{C} or of an enclosing class of \tcode{C} is accessible
8362-
unless it is a public or protected member of \tcode{C},
8363-
or a member of a base class
8364-
accessible as a public or protected member of \tcode{C}.
8365-
\end{itemize}
8366-
For names appearing in a contract condition of a non-member function,
8367-
friendship is not considered.
8368-
\begin{example}
8369-
\begin{codeblock}
8370-
class X {
8371-
public:
8372-
int v() const;
8373-
void f() [[expects: x > 0]]; // error: \tcode{x} is private
8374-
void g() [[expects: v() > 0]]; // OK
8375-
friend void r(int z) [[expects: z > 0]]; // OK
8376-
friend void s(int z) [[expects: z > x]]; // error: \tcode{x} is private
8377-
protected:
8378-
int w();
8379-
void h() [[expects: x > 0]]; // error: \tcode{x} is private
8380-
void i() [[ensures: y > 0]]; // OK
8381-
void j() [[ensures: w() > 0]]; // OK
8382-
int y;
8383-
private:
8384-
void k() [[expects: x > 0]]; // OK
8385-
int x;
8386-
};
8387-
8388-
class Y : public X {
8389-
public:
8390-
void a() [[expects: v() > 0]]; // OK
8391-
void b() [[ensures: w() > 0]]; // error: \tcode{w} is protected
8392-
protected:
8393-
void c() [[expects: w() > 0]]; // OK
8394-
};
8395-
\end{codeblock}
8396-
\end{example}
83978351

83988352
\pnum
83998353
A precondition is checked by evaluating its predicate

0 commit comments

Comments
 (0)