You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The detailed specifications of each entity defined in Clauses 7–12 follow the conventions established by
ISO/IEC 14882:2014 §17.5.1.4.
N4140 [structure.specifications] para 6 and 7:
6 If the formulation of a complexity requirement calls for a negative number of operations, the actual requirement is zero operations.
7 Complexity requirements specified in the library clauses are upper bounds, and implementations that provide better complexity guarantees satisfy the requirements.
So the specifications of copy_n and generate_n are sensible, albeit confusing. I think we can clean them up editorially. (Actually looks at copy_n) Correction, we can clean up fill_n and generate_n editorially, copy_n is just plain broken.
Proposed Resolution
Change [alg.fill] as follows:
-2 Returns: fill returns last. fill_n returns first + n for non-negative values of n and first- for negative values.+2 Returns: last, where last is first + max(n, 0) for fill_n.-3 Complexity: Exactly last - first, n, or 0 assignments, respectively.+3 Complexity: Exactly last - first assignments.
Change [alg.generate] as follows:
2 Returns: last, where last is first + max(n, 0) for generate_n.
-3 Complexity: Exactly last - first or n evaluations of invoke(gen) and assignments,- respectively.+3 Complexity: Exactly last - first evaluations of invoke(gen) and assignments.
copy_n
andgenerate_n
allow negativen
values but then specify the complexity as "exactlyn
".fill_n
handles this correctly.The text was updated successfully, but these errors were encountered: