[inplace.vector.modifiers] (original) (raw)
23 Containers library [containers]
23.3 Sequence containers [sequences]
23.3.16 Class template inplace_vector [inplace.vector]
23.3.16.5 Modifiers [inplace.vector.modifiers]
constexpr iterator insert(const_iterator position, const T& x);constexpr iterator insert(const_iterator position, T&& x);constexpr iterator insert(const_iterator position, size_type n, const T& x);template<class InputIterator> constexpr iterator insert(const_iterator position, InputIterator first, InputIterator last);template<[_container-compatible-range_](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R> constexpr iterator insert_range(const_iterator position, R&& rg);constexpr iterator insert(const_iterator position, initializer_list<T> il);template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);template<[_container-compatible-range_](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R> constexpr void append_range(R&& rg);
Let n be the value of size() before this call for the append_range overload, anddistance(begin, position) otherwise.
Complexity: Linear in the number of elements inserted plus the distance to the end of the vector.
Remarks: If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move assignment operator of T or by any InputIterator operation, there are no effects.
Otherwise, if an exception is thrown, thensize() ≥ n and elements in the range begin() + [0, n) are not modified.
constexpr reference push_back(const T& x);constexpr reference push_back(T&& x);template<class... Args> constexpr reference emplace_back(Args&&... args);
Throws: bad_alloc or any exception thrown by the initialization of the inserted element.
Remarks: If an exception is thrown, there are no effects on *this.
template<class... Args> constexpr pointer try_emplace_back(Args&&... args);constexpr pointer try_push_back(const T& x);constexpr pointer try_push_back(T&& x);
Let vals denote a pack:
- std::forward<Args>(args)... for the first overload,
- x for the second overload,
- std::move(x) for the third overload.
Preconditions: value_type is _Cpp17EmplaceConstructible_into inplace_vector from vals....
Effects: If size() < capacity() is true, appends an object of type Tdirect-non-list-initialized with vals....
Otherwise, there are no effects.
Returns: nullptr if size() == capacity() is true, otherwise addressof(back()).
Throws: Nothing unless an exception is thrown by the initialization of the inserted element.
Remarks: If an exception is thrown, there are no effects on *this.
Preconditions: value_type is _Cpp17EmplaceConstructible_into inplace_vector from
*ranges::begin(rg).
Effects: Appends copies of initial elements in rg before end(), until all elements are inserted or size() == capacity() is true.
Each iterator in the range rg is dereferenced at most once.
Returns: An iterator pointing to the first element of rgthat was not inserted into *this, or ranges::end(rg) if no such element exists.
Complexity: Linear in the number of elements inserted.
Remarks: Let n be the value of size() prior to this call.
If an exception is thrown after the insertion of k elements, thensize() equals , elements in the range begin() + [0, n) are not modified, and elements in the range begin() + [n, ) correspond to the inserted elements.
template<class... Args> constexpr reference unchecked_emplace_back(Args&&... args);
Preconditions: size() < capacity() is true.
Effects: Equivalent to:return *try_emplace_back(std::forward<Args>(args)...);
constexpr reference unchecked_push_back(const T& x);constexpr reference unchecked_push_back(T&& x);
Preconditions: size() < capacity() is true.
Effects: Equivalent to:return *try_push_back(std::forward<decltype(x)>(x));
static constexpr void reserve(size_type n);
Throws: bad_alloc if n > capacity() is true.
static constexpr void shrink_to_fit() noexcept;
constexpr iterator erase(const_iterator position);constexpr iterator erase(const_iterator first, const_iterator last);constexpr void pop_back();
Effects: Invalidates iterators and references at or after the point of the erase.
Throws: Nothing unless an exception is thrown by the assignment operator or move assignment operator of T.
Complexity: The destructor of T is called the number of times equal to the number of the elements erased, but the assignment operator of T is called the number of times equal to the number of elements after the erased elements.