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.

### 3219. `std::array` overview container requirements are incorrect

Section: 22.3.7.1 [array.overview], 22.2.1 [container.requirements.general] Status: New Submitter: Nevin Liber & Christian Trott Opened: 2019-06-13 Last modified: 2020-09-06

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 22.3.7.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.

Proposed resolution:

This wording is relative to N4810.

1. Modify 22.2.1 [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 semantics | Assertion/note pre/post-condition | Complexity
   > --- | --- | --- | --- | ---
   > `[…]`
   > `X u;` | `` |  | Ensures: `!u.empty()` for `array<T, N>` where `0 < N`, and Ensures: `u.empty()` for all other standard containers. | constant(Note A)
   > `X()` | `` |  | Ensures: `!X().empty()` for `array<T, N>` where `0 < N`, and Ensures: `X().empty()` for all other standard containers. | constant(Note A)
   > `[…]`

   > Those entries marked "(Note A)" or "(Note B)" have linear complexity for `array<T, N>` where `0 < N` and have constant complexity for all other standard containers.

2. Modify 22.3.7.1 [array.overview] as indicated:

   > -2- An `array` is an aggregate (9.4.2 [dcl.init.aggr]) that can be list-initialized with up to `N` elements whose types are convertible to `T`.

   > -3- An `array<T, 0>` satisfies all of the requirements of a container and of a reversible container (22.2 [container.requirements]). An `array<T, N>` where `0 < N` satisfies all of the requirements of a container and of a reversible container (22.2 [container.requirements]), except that a default constructed `array<T, N>` object is not empty and that both default construction and `swap` does not have constant linear complexity. An `array` satisfies some of the requirements of a sequence container (22.2.3 [sequence.reqmts]). Descriptions are provided here only for operations on `array` that are not described in one of these tables and for operations where there is additional semantic information.