|
562 | 562 | \begin{itemize}
|
563 | 563 | \item function body\iref{dcl.fct.def.general},
|
564 | 564 | \item default argument\iref{dcl.fct.default},
|
565 |
| -\item \grammarterm{noexcept-specifier}\iref{except.spec}, |
566 |
| -\item contract condition\iref{dcl.attr.contract}, or |
| 565 | +\item \grammarterm{noexcept-specifier}\iref{except.spec}, or |
567 | 566 | \item default member initializer
|
568 | 567 | \end{itemize}
|
569 | 568 | within the \grammarterm{member-specification} of the class.
|
|
4105 | 4104 | A \tcode{consteval} virtual function shall not be overridden by
|
4106 | 4105 | a virtual function that is not \tcode{consteval}.
|
4107 | 4106 |
|
4108 |
| -\pnum |
4109 |
| -If an overriding function specifies contract conditions\iref{dcl.attr.contract}, |
4110 |
| -it shall specify the same list of contract conditions as |
4111 |
| -its overridden functions; |
4112 |
| -no diagnostic is required |
4113 |
| -if corresponding conditions will always evaluate to the same value. |
4114 |
| -Otherwise, it is considered to have |
4115 |
| -the list of contract conditions from one of its overridden functions; |
4116 |
| -the names in the contract conditions are bound, |
4117 |
| -and the semantic constraints are checked, |
4118 |
| -at the point where the contract conditions appear. |
4119 |
| -Given a virtual function \tcode{f} |
4120 |
| -with a contract condition that odr-uses \tcode{*this}\iref{basic.def.odr}, |
4121 |
| -the class of which \tcode{f} is a direct member |
4122 |
| -shall be be an unambiguous and accessible base class of any class |
4123 |
| -in which \tcode{f} is overridden. |
4124 |
| -If a function overrides more than one function, |
4125 |
| -all of the overridden functions shall have |
4126 |
| -the same list of contract conditions\iref{dcl.attr.contract}; |
4127 |
| -no diagnostic is required |
4128 |
| -if corresponding conditions will always evaluate to the same value. |
4129 |
| -\begin{example} |
4130 |
| -\begin{codeblock} |
4131 |
| -struct A { |
4132 |
| - virtual void g() [[expects: x == 0]]; |
4133 |
| - int x = 42; |
4134 |
| -}; |
4135 |
| - |
4136 |
| -int x = 42; |
4137 |
| -struct B { |
4138 |
| - virtual void g() [[expects: x == 0]]; |
4139 |
| -} |
4140 |
| - |
4141 |
| -struct C : A, B { |
4142 |
| - virtual void g(); // error: preconditions of overridden functions are not the same |
4143 |
| -}; |
4144 |
| -\end{codeblock} |
4145 |
| -\end{example} |
4146 |
| - |
4147 | 4107 | \rSec2[class.abstract]{Abstract classes}%
|
4148 | 4108 |
|
4149 | 4109 | \pnum
|
|
0 commit comments