Why does an empty vector call the value type’s default constructor?
Because you’re explicitly passing an initial size, which calls a constructor that has another parameter whose default value is s(). Just leave out the (0) (i.e. std::vector<s> v;) and it won’t happen. For completeness, the Standard 23.2.4-2 defines the constructor you’re calling as: explicit vector(size_type n, const T& value =T(), const Allocator& = Allocator()); Aside … Read more