I'm trying to shrink the size of a vector that I have, but i get an error when i use the myvector.shrink_to_fit();
and it tells me:
error: no member named '
shrink_to_fit' in 'std::vector<double, std::allocator<double> >'
and myvector is defined in the header as:
std::vector<double> myvector;
what does this error mean?
shrink_to_fit is a new C++11 feature that won't be in every compiler yet.
The old way of doing this was to swap with a temporary:
std::vector<double>(myvector).swap(myvector);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With