Files
2025-10-25 03:02:53 +03:00

99 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[deque.capacity]
# 23 Containers library [[containers]](./#containers)
## 23.3 Sequence containers [[sequences]](sequences#deque.capacity)
### 23.3.5 Class template deque [[deque]](deque#capacity)
#### 23.3.5.3 Capacity [deque.capacity]
[🔗](#lib:resize,deque)
`constexpr void resize(size_type sz);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6722)
*Preconditions*: T is *Cpp17MoveInsertable* and *Cpp17DefaultInsertable* into deque[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6726)
*Effects*: If sz < size(), erases the last size() - sz elements
from the sequence[.](#2.sentence-1)
Otherwise,
appends sz - size() default-inserted elements to the sequence[.](#2.sentence-2)
[🔗](#lib:resize,deque_)
`constexpr void resize(size_type sz, const T& c);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6739)
*Preconditions*: T is *Cpp17CopyInsertable* into deque[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6743)
*Effects*: If sz < size(), erases the last size() - sz elements
from the sequence[.](#4.sentence-1)
Otherwise,
appends sz - size() copies of c to the sequence[.](#4.sentence-2)
[🔗](#lib:shrink_to_fit,deque)
`constexpr void shrink_to_fit();
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6756)
*Preconditions*: T is *Cpp17MoveInsertable* into deque[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6760)
*Effects*: shrink_to_fit is a non-binding request to reduce memory use
but does not change the size of the sequence[.](#6.sentence-1)
[*Note [1](#note-1)*:
The request is non-binding to allow latitude for
implementation-specific optimizations[.](#6.sentence-2)
— *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[.](#6.sentence-3)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6773)
*Complexity*: If the size is not equal to the old capacity,
linear in the size of the sequence;
otherwise constant[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L6779)
*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[.](#8.sentence-1)