Constructs a container with n elements. Each element is a copy of val (if provided).

(3) range constructor

Constructs a container with as many elements as the range [first,last), with each element emplace-constructed from its corresponding element in that range, in the same order.

(4) copy constructor (and copying with allocator)

Constructs a container with a copy of each of the elements in x, in the same order.

(5) move constructor (and moving with allocator)

Constructs a container that acquires the elements of x.
If alloc is specified and is different from x's allocator, the elements are moved. Otherwise, no elements are constructed (their ownership is directly transferred).x is left in an unspecified but valid state.

(6) initializer list constructor

Constructs a container with a copy of each of the elements in il, in the same order.

The container keeps an internal copy of alloc, which is used to allocate and deallocate storage for its elements, and to construct and destroy them (as specified by its allocator_traits). If no alloc argument is passed to the constructor, a default-constructed allocator is used, except in the following cases:
- The copy constructor (4, first signature) creates a container that keeps and uses a copy of the allocator returned by calling the appropriate selected_on_container_copy_construction trait on x's allocator.
- The move constructor (5, first signature) acquires x's allocator.

Parameters

alloc

Allocator object.
The container keeps and uses an internal copy of this allocator.
Member type allocator_type is the internal allocator type used by the container, defined in vector as an alias of its second template parameter (Alloc).
If allocator_type is an instantiation of the default allocator (which has no state), this is not relevant.

n

Initial container size (i.e., the number of elements in the container at construction).
Member type size_type is an unsigned integral type.

val

Value to fill the container with. Each of the n elements in the container will be initialized to a copy of this value.
Member type value_type is the type of the elements in the container, defined in vector as an alias of its first template parameter (T).

first, last

Input iterators to the initial and final positions in a range. The range used is [first,last), which includes all the elements between first and last, including the element pointed by first but not the element pointed by last.
The function template argument InputIterator shall be an input iterator type that points to elements of a type from which value_type objects can be constructed.

x

Another vector object of the same type (with the same class template arguments T and Alloc), whose contents are either copied or acquired.

il

An initializer_list object.
These objects are automatically constructed from initializer list declarators.
Member type value_type is the type of the elements in the container, defined in vector as an alias of its first template parameter (T).

Complexity

Constant for the default constructor (1), and for the move constructors (5) (unless alloc is different from x's allocator).
For all other cases, linear in the resulting container size.
Additionally, if InputIterator in the range constructor (3) is not at least of a forward iterator category (i.e., it is just an input iterator), the new capacity cannot be determined beforehand and the construction incurs in additional logarithmic complexity in size (reallocations while growing).

Iterator validity

The move constructors (5), invalidate all iterators, pointers and references related to x if the elements are moved.

Data races

All copied elements are accessed.
The move constructors (5) modify x.

Exception safety

Strong guarantee: no effects in case an exception is thrown.
If allocator_traits::construct is not supported with the appropriate arguments for the element constructions, or if the range specified by [first,last) is not valid, it causes undefined behavior.