English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C++ Deque (Double-ended Queue)
C ++ The Dequerink_to_fit() function reduces the container size to the size of the storage space occupied by the elements. This function does not modify the content of the deque.
void shrink_to_fit();
It does not contain any parameters.
It does not return any value.
Let's see a simple example
#include<iostream> #include<deque> using namespace std; int main() { deque<int> d={1,2,3,4,5}; cout << "size: " << d.size(); d.resize(3); cout << '\n'; cout << "size:" << d.size(); d.shrink_to_fit(); return 0; }