With C++11, you can call the member function shrink_to_fit()
. The draft standard section 23.2.6.2 says:
shrink_to_fit
is a non-binding request
to reducecapacity()
tosize()
. [Note: The request is non-binding to
allow latitude for
implementation-specific optimizations.
—end note]