4.6 KiB
[vector.cons]
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.
Complexity: Constant.
constexpr explicit vector(size_type n, const Allocator& = Allocator());
Preconditions: T is Cpp17DefaultInsertable into vector.
Effects: Constructs a vector with n default-inserted elements using the specified allocator.
Complexity: Linear in n.
constexpr vector(size_type n, const T& value, const Allocator& = Allocator());
Preconditions: T isCpp17CopyInsertable into vector.
Effects: Constructs a vector with n copies of value, using the specified allocator.
Complexity: Linear in n.
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 N calls to the copy constructor ofT (where N is the distance betweenfirst andlast) and no reallocations ifInputIterator meets the Cpp17ForwardIterator requirements.
It makes orderN calls to the copy constructor ofT and orderlogN reallocations if they are just input iterators.
template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R> constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());
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 logN reallocations and order N calls to the copy or move constructor of T.