This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.
Section: 16.3.2.4[structure.specifications]Status:C++11Submitter: Thomas PlumOpened: 2009-03-03Last modified: 2016-01-28
Priority:Not Prioritized
View otheractive issues in [structure.specifications].
View all otherissues in [structure.specifications].
View all issues withC++11 status.
Discussion:
Addresses UK-163 [CD1]
Many functions are defined as "Effects: Equivalent to a...", which seemsto also define the preconditions, effects, etc. But this is not madeclear.
After studying the occurrences of "Effects: Equivalent to", I agree withthe diagnosis but disagree with the solution. In 27.4.3.3[string.cons]we find
14Effects: If
InputIteratoris an integral type, equivalent tobasic_string(static_cast<size_type>(begin), static_cast<value_type>(end), a)15 Otherwise constructs a string from the values in the range
[begin,end), as indicated in the Sequence Requirements table (see 23.1.3).
This would be devishly difficult to re-write with an explicit"Equivalent to:" clause. Instead, I propose the following, which willresult in much less editorial re-work.
[2009-05-09 Alisdair adds:]
[Batavia (2009-05):]
We agree with the proposed resolution.Move to Tentatively Ready.
Proposed resolution:
Add a new paragraph after 16.3.2.4[structure.specifications], p3:
-3- Descriptions of function semantics contain the following elements (as appropriate):154
- Requires: the preconditions for calling the function
- Effects: the actions performed by 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 theEffects element specifies that the semantics of somefunction
FareEquivalent to somecode-sequence, thenthe various elements are interpreted as follows. IfF'ssemantics specifies aRequires element, then that requirement islogically imposed prior to theequivalent-to semantics. Then,the semantics of thecode-sequence are determined by theRequires,Effects,Postconditions,Returns,Throws,Complexity,Remarks,ErrorConditions andNotes specified for the (one or more) functioninvocations contained in thecode-sequence. The value returned fromFis specified byF'sReturns element, orifFhas noReturns element, a non-voidreturn fromFis specified by theReturns elements incode-sequence. IfF's semantics contains aThrows (orPostconditions, orComplexity) element, then thatsupersedes any occurrences of that element in thecode-sequence.