[deque.capacity] (original) (raw)

23 Containers library [containers]

23.3 Sequence containers [sequences]

23.3.5 Class template deque [deque]

23.3.5.3 Capacity [deque.capacity]

constexpr void resize(size_type sz);

Preconditions: T is Cpp17MoveInsertable and Cpp17DefaultInsertable into deque.

Effects: If sz < size(), erases the last size() - sz elements from the sequence.

Otherwise, appends sz - size() default-inserted elements to the sequence.

constexpr void resize(size_type sz, const T& c);

Preconditions: T is Cpp17CopyInsertable into deque.

Effects: If sz < size(), erases the last size() - sz elements from the sequence.

Otherwise, appends sz - size() copies of c to the sequence.

constexpr void shrink_to_fit();

Preconditions: T is Cpp17MoveInsertable into deque.

Effects: shrink_to_fit is a non-binding request to reduce memory use but does not change the size of the sequence.

[Note 1:

The request is non-binding to allow latitude for implementation-specific optimizations.

— _end note_]

If the size is equal to the old capacity, or if an exception is thrown other than by the move constructor of a non-Cpp17CopyInsertable T, then there are no effects.

Complexity: If the size is not equal to the old capacity, linear in the size of the sequence; otherwise constant.

Remarks: If the size is not equal to the old capacity, then invalidates all the references, pointers, and iterators referring to the elements in the sequence, as well as the past-the-end iterator.