17 Library introduction [library]

17.5 Method of description (Informative) [description]

17.5.1 Structure of each clause [structure]

17.5.1.4 Detailed specifications [structure.specifications]

The detailed specifications each contain the following elements:

  • name and brief description

  • synopsis (class definition or function prototype, as appropriate)

  • restrictions on template arguments, if any

  • description of class invariants

  • description of function semantics

Descriptions of class member functions follow the order (as appropriate):163

  • constructor(s) and destructor

  • copying, moving & assignment functions

  • comparison functions

  • modifier functions

  • observer functions

  • operators and other non-member functions

Descriptions of function semantics contain the following elements (as appropriate):164

  • Requires: the preconditions for calling the function

  • Effects: the actions performed by the function

  • Synchronization: the synchronization operations ([intro.multithread]) applicable to the function

  • Postconditions: the observable results established by the function

  • Returns: a description of the value(s) returned by the function

  • Throws: any exceptions thrown by the function, and the conditions that would cause the exception

  • Complexity: the time and/or space complexity of the function

  • Remarks: additional semantic constraints on the function

  • Error conditions: the error conditions for error codes reported by the function.

  • Notes: non-normative comments about the function

Whenever the Effects: element specifies that the semantics of some function F are Equivalent to some code sequence, then the various elements are interpreted as follows. If F's semantics specifies a Requires: element, then that requirement is logically imposed prior to the equivalent-to semantics. Next, the semantics of the code sequence are determined by the Requires:, Effects:, Postconditions:, Returns:, Throws:, Complexity:, Remarks:, Error conditions:, and Notes: specified for the function invocations contained in the code sequence. The value returned from F is specified by F's Returns: element, or if F has no Returns: element, a non-void return from F is specified by the Returns: elements in the code sequence. If F's semantics contains a Throws:, Postconditions:, or Complexity: element, then that supersedes any occurrences of that element in the code sequence.

For non-reserved replacement and handler functions, Clause [language.support] specifies two behaviors for the functions in question: their required and default behavior. The default behavior describes a function definition provided by the implementation. The required behavior describes the semantics of a function definition provided by either the implementation or a C++ program. Where no distinction is explicitly made in the description, the behavior described is the required behavior.

If the formulation of a complexity requirement calls for a negative number of operations, the actual requirement is zero operations.165

Complexity requirements specified in the library clauses are upper bounds, and implementations that provide better complexity guarantees satisfy the requirements.

Error conditions specify conditions where a function may fail. The conditions are listed, together with a suitable explanation, as the enum class errc constants ([syserr]).

To save space, items that do not apply to a class are omitted. For example, if a class does not specify any comparison functions, there will be no “Comparison functions” subclause.

To save space, items that do not apply to a function are omitted. For example, if a function does not specify any further preconditions, there will be no “Requires” paragraph.

This simplifies the presentation of complexity requirements in some cases.