21
Containers library
[containers]
21.3
Sequence containers
[sequences]
21.3.8
Class template
deque
[deque]
21.3.8.3
Capacity
[deque.capacity]
🔗
void resize(size_type sz);
1
#
Effects:
If
sz < size()
, erases the last
size() - sz
elements from the sequence
.
Otherwise, appends
sz - size()
default-inserted elements to the sequence
.
2
#
Requires:
T
shall be
Cpp17MoveInsertable
and
Cpp17DefaultInsertable
into
*this
.
🔗
void resize(size_type sz, const T& c);
3
#
Effects:
If
sz < size()
, erases the last
size() - sz
elements from the sequence
.
Otherwise, appends
sz - size()
copies of
c
to the sequence
.
4
#
Requires:
T
shall be
Cpp17CopyInsertable
into
*this
.
🔗
void shrink_to_fit();
5
#
Requires:
T
shall be
Cpp17MoveInsertable
into
*this
.
6
#
Effects:
shrink_to_fit
is a non-binding request to reduce memory use but does not change the size of the sequence
.
[
 
Note
:
The request is non-binding to allow latitude for implementation-specific optimizations
.
—
 
end note
 
]
If an exception is thrown other than by the move constructor of a non-
Cpp17CopyInsertable
T
there are no effects
.
7
#
Complexity:
Linear in the size of the sequence
.
8
#
Remarks:
shrink_to_fit
invalidates all the references, pointers, and iterators referring to the elements in the sequence as well as the past-the-end iterator
.