Files
cppdraft_translate/cppdraft/deque/capacity.md
2025-10-25 03:02:53 +03:00

2.8 KiB

[deque.capacity]

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);

1

#

Preconditions: T is Cpp17MoveInsertable and Cpp17DefaultInsertable into deque.

2

#

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);

3

#

Preconditions: T is Cpp17CopyInsertable into deque.

4

#

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();

5

#

Preconditions: T is Cpp17MoveInsertable into deque.

6

#

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.

7

#

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

8

#

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.