I am facing a problem with shrink_to_fit() function of STL C++. The problem is which I use it, the compiler gives error "Method 'shrink_to_fit' could not be resolved" on Eclipse Luna (32 bit) with MinGW compiler but the same program works fine in Dev C++.
Compiler do not recommend shrink_to_fit() after using dot(.):
Original code:
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
vector<int> v(128);
cout << "Initial capacity = " << v.capacity() << endl;
v.resize(25);
cout << "Capacity after resize = " << v.capacity() << endl;
v.shrink_to_fit();
cout << "Capacity after shrink_to_fit = " << v.capacity() << endl;
return 0;
}
Please let me know is this my fault or IDE's.
P.S. I am using C++14.