I read on the Internet that if you are clearing a std::vector repetitively (in a tight loop), it might be better to use resize(0) instead of
There appears to be a difference between clear and resize(0) when the vector contains objects of a class that does not have a default constructor. For example, the following code will compile:
#include
class A {
private:
int x,y;
public:
A(int x,int y) :x(x), y(y) {}
};
int main() {
std::vector aa;
aa.clear();
}
But if you substitute the aa.clear() by aa.resize(0), you get compilation error:
error: no matching function for call to 'A::A()'