|
495 | 495 |
|
496 | 496 | \pnum
|
497 | 497 | Descriptions of function semantics contain the following elements (as
|
498 |
| -appropriate):\footnote{To save space, items that do not apply to a function are omitted. |
499 |
| -For example, if a function does not specify any |
500 |
| -further |
501 |
| -preconditions, there will be no \requires paragraph.} |
| 498 | +appropriate):\footnote{To save space, elements that do not apply to a function are omitted. |
| 499 | +For example, if a function specifies no |
| 500 | +preconditions, there will be no \expects element.} |
502 | 501 |
|
503 | 502 | \begin{itemize}
|
504 |
| -\item \requires the preconditions for calling the function |
505 |
| -\item \effects the actions performed by the function |
506 |
| -\item \sync the synchronization operations\iref{intro.multithread} applicable to the function |
507 |
| -\item \postconditions the observable results established by the function |
508 |
| -\item \returns a description of the value(s) returned by the function |
509 |
| -\item \throws any exceptions thrown by the function, and the conditions that would cause the exception |
510 |
| -\item \complexity the time and/or space complexity of the function |
511 |
| -\item \remarks additional semantic constraints on the function |
512 |
| -\item \errors the error conditions for error codes reported by the function |
| 503 | +\item |
| 504 | +\requires the preconditions for calling the function. |
| 505 | + |
| 506 | +\item |
| 507 | +\constraints the conditions for the function's participation |
| 508 | +in overload resolution\iref{over.match}. |
| 509 | +\begin{note} |
| 510 | +Failure to meet such a condition results in the function's silent non-viability. |
| 511 | +\end{note} |
| 512 | +\begin{example} |
| 513 | +An implementation might express such a condition |
| 514 | +via a \grammarterm{constraint-expression}\iref{temp.constr.decl}. |
| 515 | +\end{example} |
| 516 | + |
| 517 | +\item |
| 518 | +\mandates the conditions that, if not met, render the program ill-formed. |
| 519 | +\begin{example} |
| 520 | +An implementation might express such a condition |
| 521 | +via the \grammarterm{constant-expression} |
| 522 | +in a \grammarterm{static\_assert-declaration}\iref{dcl.dcl}. |
| 523 | +If the diagnostic is to be emitted only after the function |
| 524 | +has been selected by overload resolution, |
| 525 | +an implementation might express such a condition |
| 526 | +via a \grammarterm{constraint-expression}\iref{temp.constr.decl} |
| 527 | +and also define the function as deleted. |
| 528 | +\end{example} |
| 529 | + |
| 530 | +\item |
| 531 | +\expects the conditions (sometimes termed preconditions) |
| 532 | +that the function assumes to hold whenever it is called. |
| 533 | +\begin{example} |
| 534 | +An implementation might express such conditions |
| 535 | +via an attribute such as \tcode{[[expects]]}\iref{dcl.attr.contract}. |
| 536 | +However, some such conditions might not lend themselves |
| 537 | +to expression via code. |
| 538 | +\end{example} |
| 539 | + |
| 540 | +\item |
| 541 | +\effects the actions performed by the function. |
| 542 | + |
| 543 | +\item |
| 544 | +\sync the synchronization operations\iref{intro.multithread} applicable to the function. |
| 545 | + |
| 546 | +\item |
| 547 | +\ensures the conditions (sometimes termed observable results or postconditions) |
| 548 | +established by the function. |
| 549 | + |
| 550 | +\item |
| 551 | +\returns a description of the value(s) returned by the function. |
| 552 | + |
| 553 | +\item |
| 554 | +\throws any exceptions thrown by the function, and the conditions that would cause the exception. |
| 555 | + |
| 556 | +\item |
| 557 | +\complexity the time and/or space complexity of the function. |
| 558 | + |
| 559 | +\item |
| 560 | +\remarks additional semantic constraints on the function. |
| 561 | + |
| 562 | +\item |
| 563 | +\errors the error conditions for error codes reported by the function. |
513 | 564 | \end{itemize}
|
514 | 565 |
|
515 | 566 | \pnum
|
516 | 567 | Whenever the \Fundescx{Effects} element specifies that the semantics of some function
|
517 | 568 | \tcode{F} are \term{Equivalent to} some code sequence, then the various elements are
|
518 |
| -interpreted as follows. If \tcode{F}'s semantics specifies a \Fundescx{Requires} element, then |
519 |
| -that requirement is logically imposed prior to the \term{equivalent-to} semantics. |
520 |
| -Next, the semantics of the code sequence are determined by the \Fundescx{Requires}, \Fundescx{Effects}, |
521 |
| -\Fundescx{Synchronization}, \Fundescx{Postconditions}, \Fundescx{Returns}, \Fundescx{Throws}, \Fundescx{Complexity}, \Fundescx{Remarks}, and \Fundescx{Error conditions} |
522 |
| -specified for the function invocations contained in the code sequence. The value |
523 |
| -returned from \tcode{F} is specified by \tcode{F}'s \Fundescx{Returns} element, or if \tcode{F} |
524 |
| -has no \Fundescx{Returns} element, a non-\tcode{void} return from \tcode{F} is specified by the |
| 569 | +interpreted as follows. |
| 570 | +If \tcode{F}'s semantics specifies any \Fundescx{Constraints} or \Fundescx{Mandates} elements, |
| 571 | +then those requirements are logically imposed prior to the \term{equivalent-to} semantics. |
| 572 | +Next, the semantics of the code sequence are determined by the |
| 573 | +\Fundescx{Constraints}, \Fundescx{Mandates}, \Fundescx{Expects}, \Fundescx{Effects}, |
| 574 | +\Fundescx{Synchronization}, \Fundescx{Ensures}, \Fundescx{Returns}, \Fundescx{Throws}, |
| 575 | +\Fundescx{Complexity}, \Fundescx{Remarks}, and \Fundescx{Error conditions} |
| 576 | +specified for the function invocations contained in the code sequence. |
| 577 | +The value returned from \tcode{F} is specified by \tcode{F}'s \Fundescx{Returns} element, |
| 578 | +or if \tcode{F} has no \Fundescx{Returns} element, |
| 579 | +a non-\tcode{void} return from \tcode{F} is specified by the |
525 | 580 | \tcode{return} statements\iref{stmt.return} in the code sequence.
|
526 | 581 | If \tcode{F}'s semantics contains a \Fundescx{Throws},
|
527 |
| -\Fundescx{Postconditions}, or \Fundescx{Complexity} element, then that supersedes any occurrences of that |
528 |
| -element in the code sequence. |
| 582 | +\Fundescx{Ensures}, or \Fundescx{Complexity} element, |
| 583 | +then that supersedes any occurrences of that element in the code sequence. |
529 | 584 |
|
530 | 585 | \pnum
|
531 | 586 | For non-reserved replacement and handler functions,
|
|
2737 | 2792 |
|
2738 | 2793 | \pnum
|
2739 | 2794 | \indextext{restriction}%
|
2740 |
| -Violation of the preconditions specified in a function's |
| 2795 | +Violation of any preconditions specified in a function's |
2741 | 2796 | \requires
|
2742 |
| -paragraph results in undefined behavior unless the function's |
| 2797 | +element results in undefined behavior unless the function's |
2743 | 2798 | \throws
|
2744 |
| -paragraph specifies throwing an exception when the precondition is violated. |
| 2799 | +element specifies throwing an exception when the precondition is violated. |
| 2800 | + |
| 2801 | +\pnum |
| 2802 | +Violation of any preconditions specified |
| 2803 | +in a function's \expects element |
| 2804 | +results in undefined behavior. |
2745 | 2805 |
|
2746 | 2806 | \rSec2[conforming]{Conforming implementations}
|
2747 | 2807 |
|
|
0 commit comments