[vector.cons] (original) (raw)
23 Containers library [containers]
23.3 Sequence containers [sequences]
23.3.13 Class template vector [vector]
23.3.13.2 Constructors [vector.cons]
constexpr explicit vector(const Allocator&) noexcept;
Effects: Constructs an empty vector, using the specified allocator.
constexpr explicit vector(size_type n, const Allocator& = Allocator());
Preconditions: T is Cpp17DefaultInsertable into vector.
Effects: Constructs a vector with ndefault-inserted elements using the specified allocator.
constexpr vector(size_type n, const T& value,const Allocator& = Allocator());
Preconditions: T is_Cpp17CopyInsertable_ into vector.
Effects: Constructs a vector with ncopies of value, using the specified allocator.
template<class InputIterator> constexpr vector(InputIterator first, InputIterator last,const Allocator& = Allocator());
Effects: Constructs a vector equal to the range [first, last), using the specified allocator.
Complexity: Makes only Ncalls to the copy constructor ofT(where Nis the distance betweenfirstandlast) and no reallocations if iterators first and last are of forward, bidirectional, or random access categories.
It makes orderNcalls to the copy constructor ofTand orderreallocations if they are just input iterators.
Effects: Constructs a vector object with the elements of the range rg, using the specified allocator.
Complexity: Initializes exactly N elements from the results of dereferencing successive iterators of rg, where N is ranges::distance(rg).
Performs no reallocations if:
- R models ranges::approximately_sized_range, andranges::distance(rg) <= ranges::reserve_hint(rg) is true, or
- R models ranges::forward_range andR does not model ranges::approximately_sized_range.
Otherwise, performs order reallocations and order N calls to the copy or move constructor of T.