This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.

### 2231. DR 704 removes complexity guarantee for `clear()`

Section: 22.2.3 [sequence.reqmts] Status: C++14 Submitter: Jonathan Wakely Opened: 2012-12-30 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [sequence.reqmts].

View all other issues in [sequence.reqmts].

View all issues with C++14 status.

Discussion:

From the question at stackoverflow.

Were we aware that the resolution to LWG 704 means there is no complexity guarantee for `clear()` on most sequence containers? Previously it was implied by defining it in terms of `erase(begin(), end())` but we no longer do that.

There are explicit complexity requirements for `std::list::clear()`, but not the other sequence containers.

Daniel:

The idea was that the notion of "destroys all elements in `a`" would imply a linear complexity, but the wording needs to be clearer, because this doesn't say that this step is the actual complexity bound.

[2013-03-15 Issues Teleconference]

Moved to Tentatively Ready.

[2013-04-20 Bristol]

Proposed resolution:

This wording is relative to N3485.

1. Change Table 100 as indicated:

   > Table 100 — Sequence container requirements (in addition to container) (continued)
   > Expression | Return type | Assertion/note pre-/post-condition
   > --- | --- | ---
   > `…`
   > `a.clear()` | `void` | Destroys all elements in `a`. Invalidates all references, pointers, and iterators referring to the elements of `a` and may invalidate the past-the-end iterator. post: `a.empty()` returns `true` complexity: linear
   > `…`