Force a std::vector to free its memory?
Use the swap trick:
#include <vector>
template <typename T>
void FreeAll( T & t ) {
T tmp;
t.swap( tmp );
}
int main() {
std::vector <int> v;
v.push_back( 1 );
FreeAll( v );
}
Consider using the swap trick:
std::vector<Shape>().swap(shapes);