This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
std::array overview container requirements are incorrectSection: 23.3.3.1 [array.overview], 23.2.2 [container.requirements.general] Status: New Submitter: Nevin Liber & Christian Trott Opened: 2019-06-13 Last modified: 2022-04-24
Priority: 3
View other active issues in [array.overview].
View all other issues in [array.overview].
View all issues with New status.
Discussion:
The requirements specified in 23.3.3.1 [array.overview] p3 are incorrect; namely:
A default constructed array<T, N> where 0 < N has linear,
not constant complexity.
A default constructed array<T, 0> is empty and has constant complexity.
[2019-07 Issue Prioritization]
Priority to 3 after discussion on the reflector.
Previous resolution [SUPERSEDED]:
This wording is relative to N4810.
Modify 23.2.2 [container.requirements.general], Table 62 — "Container requirements", as indicated (This table can be identified by the "section" identifier [tab:container.req] in the next working draft):
Table 62 — Container requirements Expression Return type Operational
semanticsAssertion/note
pre/post-conditionComplexity […]X u;
Ensures:u.empty()constantX()
Ensures:X().empty()constant[…]Those entries marked "(Note A)" or "(Note B)" have linear complexity for
arrayand have constant complexity for all other standard containers.Modify 23.3.3.1 [array.overview] as indicated:
-2- An
-3- Anarrayis an aggregate (9.5.2 [dcl.init.aggr]) that can be list-initialized with up toNelements whose types are convertible toT.arraysatisfies all of the requirements of a container and of a reversible container (23.2 [container.requirements]), except that a default constructedarrayobject is not empty andthatswapdoes nothaveconstantcomplexity. Anarraysatisfies some of the requirements of a sequence container (23.2.4 [sequence.reqmts]). Descriptions are provided here only for operations onarraythat are not described in one of these tables and for operations where there is additional semantic information.
[2022-04-24; Daniel rebases wording on N4910]
Proposed resolution:
This wording is relative to N4910.
Modify 23.2.2.2 [container.reqmts] as indicated:
X u; X u = X();[…]-10- Postconditions:
-11- Complexity:u.empty()Constant.X u(rv); X u = rv;[…]-15- Postconditions:
-11- Complexity: Linear foruis equal to the value thatrvhad before this construction.arrayand constant for all other standard containers.a.swap(b)-45- Result:
-46- Effects: Exchanges the contents ofvoidaandb. -47- Complexity: Linear forarrayand constant for all other standard containers.
Modify 23.3.3.1 [array.overview] as indicated:
-2- An
-3- Anarrayis an aggregate (9.5.2 [dcl.init.aggr]) that can be list-initialized with up toNelements whose types are convertible toT.arraymeets all of the requirements of a container (23.2.2.2 [container.reqmts]) and of a reversible container (23.2.2.3 [container.rev.reqmts]), except that a default constructedarrayobject is not empty ifN > 0. Anarraymeets some of the requirements of a sequence container (23.2.4 [sequence.reqmts]). Descriptions are provided here only for operations onarraythat are not described in one of these tables and for operations where there is additional semantic information.