This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofCD1 status.
Section: 26.7.5[alg.replace]Status:CD1Submitter: Martin SeborOpened: 2000-12-15Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [alg.replace].
View all issues withCD1 status.
Duplicate of:483
Discussion:
(revision of the further discussion)There are a number of problems with the requires clauses for thealgorithms in 25.1 and 25.2. The requires clause of each algorithmshould describe the necessary and sufficient requirements on the inputsto the algorithm such that the algorithm compiles and runs properly.Many of the requires clauses fail to do this. Here is a summary of the kindsof mistakes:
Here is the list of algorithms that contain mistakes:
Also, in the requirements for EqualityComparable, the requirement thatthe operator be defined for const objects is lacking.
Proposed resolution:
20.1.1 Change p1 from
In Table 28,T is a type to be supplied by a C++ programinstantiating a template,a,b, andc arevalues of typeT.
to
In Table 28,T is a type to be supplied by a C++ programinstantiating a template,a,b, andc arevalues of typeconst T.
25 Between p8 and p9
Add the following sentence:
When the description of an algorithm gives an expression such as*first == value for a condition, it is required that the expressionevaluate to either true or false in boolean contexts.
25.1.2 Change p1 by deleting the requires clause.
25.1.6 Change p1 by deleting the requires clause.
25.1.9
Change p4 from
-4- Requires: TypeT isEqualityComparable(20.1.1), type Size is convertible to integral type (4.7.12.3).
to
-4- Requires: The typeSize is convertible to integraltype (4.7.12.3).
25.2.4 Change p1 from
-1- Requires: TypeT isAssignable (23.1 ) (and, forreplace(),EqualityComparable (20.1.1 )).
to
-1- Requires: The expression*first = new_value must be valid.
and change p4 from
-4- Requires: TypeT isAssignable (23.1) (and,forreplace_copy(),EqualityComparable(20.1.1)). The ranges[first, last) and[result, result +(last - first)) shall not overlap.
to
-4- Requires: The results of the expressions*first andnew_value must be writable to the result output iterator. Theranges[first, last) and[result, result + (last -first)) shall not overlap.
25.2.5 Change p1 from
-1- Requires: TypeT isAssignable (23.1). ThetypeSize is convertible to an integral type (4.7.12.3).
to
-1- Requires: The expressionvalue must be is writable tothe output iterator. The typeSize is convertible to anintegral type (4.7.12.3).
25.2.7 Change p1 from
-1- Requires: TypeT isEqualityComparable (20.1.1).
to
-1- Requires: The value type of the iterator must beAssignable (23.1).
Rationale:
The general idea of the proposed solution is to remove the faultyrequires clauses and let the returns and effects clauses speak forthemselves. That is, the returns clauses contain expressions that mustbe valid, and therefore already imply the correct requirements. Inaddition, a sentence is added at the beginning of chapter 25 sayingthat expressions given as conditions must evaluate to true or false ina boolean context. An alternative would be to say that the type ofthese condition expressions must be literally bool, but that would beimposing a greater restriction that what the standard currently says(which is convertible to bool).