Using g++, I observe that creating a vector of size zero calls the vector's parameterized object type's constructor once. It then is deleted. Why does this happen?
#include <iostream>
#include <vector>
using namespace std;
class s
{
public:
s() { cout << endl << "default s constructor" << endl; }
~s() { cout << endl << "default s destructor" << endl; }
};
int main()
{
vector<s> v(0);
}
Output:
default s constructor
default s destructor