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?
The actual constructor you are calling is (from cplusplus.com):
explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
So even though you only specify the size, a new T
object is created for second parameter, and will therefore also be destroyed at the conclusion of the constructor.