vector::shrink_to_fit

초과 용량을 포기 합니다.

void shrink_to_fit(
);

예제

// vector_shrink_to_fit.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;   
   vector <int> v1;
   //vector <int>::iterator Iter;

   v1.push_back( 1 );
   cout << "Current capacity of v1 = " 
      << v1.capacity( ) << endl;
   v1.reserve( 20 );
   cout << "Current capacity of v1 = " 
      << v1.capacity( ) << endl;
   v1.shrink_to_fit();
   cout << "Current capacity of v1 = " 
      << v1.capacity( ) << endl;
}
  

요구 사항

헤더: <vector>

네임 스페이스: std

참고 항목

참조

vector Class

표준 템플릿 라이브러리