FrozenHeart
FrozenHeart

Reputation: 20756

Can I construct std::vector with zero elements via the non-default constructor

I mean something like this:

std::vector<T> v(0);

Is it ok? I don't see any requirements like this in the Standard.

Upvotes: 3

Views: 61

Answers (1)

Brian Bi
Brian Bi

Reputation: 119382

This is well-defined. The standard does not place any restrictions on the value of n passed to this constructor. 0 is a valid value of type size_type (whatever that is).

Upvotes: 6

Related Questions