577 lines
26 KiB
Markdown
577 lines
26 KiB
Markdown
[inplace.vector]
|
||
|
||
# 23 Containers library [[containers]](./#containers)
|
||
|
||
## 23.3 Sequence containers [[sequences]](sequences#inplace.vector)
|
||
|
||
### 23.3.16 Class template inplace_vector [inplace.vector]
|
||
|
||
#### [23.3.16.1](#overview) Overview [[inplace.vector.overview]](inplace.vector.overview)
|
||
|
||
[1](#overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10713)
|
||
|
||
An inplace_vector is a contiguous container[.](#overview-1.sentence-1)
|
||
|
||
Its capacity is fixed and
|
||
its elements are stored within the inplace_vector object itself[.](#overview-1.sentence-2)
|
||
|
||
[2](#overview-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10719)
|
||
|
||
An inplace_vector meets all of the requirements
|
||
of a container ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")),
|
||
of a reversible container ([[container.rev.reqmts]](container.rev.reqmts "23.2.2.3 Reversible container requirements")),
|
||
of a contiguous container, and
|
||
of a sequence container,
|
||
including most of the optional sequence container requirements ([[sequence.reqmts]](sequence.reqmts "23.2.4 Sequence containers"))[.](#overview-2.sentence-1)
|
||
|
||
The exceptions are thepush_front,prepend_range,pop_front, andemplace_front member functions, which are not provided[.](#overview-2.sentence-2)
|
||
|
||
Descriptions are provided here only
|
||
for operations on inplace_vector that
|
||
are not described in one of these tables or
|
||
for operations where there is additional semantic information[.](#overview-2.sentence-3)
|
||
|
||
[3](#overview-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10737)
|
||
|
||
For any N,inplace_vector<T, N>::iterator andinplace_vector<T, N>::const_iterator meet the constexpr iterator requirements[.](#overview-3.sentence-1)
|
||
|
||
[4](#overview-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10743)
|
||
|
||
Any member function of inplace_vector<T, N> that
|
||
would cause the size to exceed N throws an exception of type bad_alloc[.](#overview-4.sentence-1)
|
||
|
||
[5](#overview-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10748)
|
||
|
||
Let IV denote a specialization of inplace_vector<T, N>[.](#overview-5.sentence-1)
|
||
|
||
If N is zero, thenIV is trivially copyable and empty, andstd::is_trivially_default_constructible_v<IV> is true[.](#overview-5.sentence-2)
|
||
|
||
Otherwise:
|
||
|
||
- [(5.1)](#overview-5.1)
|
||
|
||
If is_trivially_copy_constructible_v<T> is true, thenIV has a trivial copy constructor[.](#overview-5.1.sentence-1)
|
||
|
||
- [(5.2)](#overview-5.2)
|
||
|
||
If is_trivially_move_constructible_v<T> is true, thenIV has a trivial move constructor[.](#overview-5.2.sentence-1)
|
||
|
||
- [(5.3)](#overview-5.3)
|
||
|
||
If is_trivially_destructible_v<T> is true, then:
|
||
* [(5.3.1)](#overview-5.3.1)
|
||
|
||
IV has a trivial destructor.
|
||
|
||
* [(5.3.2)](#overview-5.3.2)
|
||
|
||
If is_trivially_copy_constructible_v<T> && is_trivially_copy_assignable_v<T> is true, then IV has a trivial copy assignment operator.
|
||
|
||
* [(5.3.3)](#overview-5.3.3)
|
||
|
||
If is_trivially_move_constructible_v<T> && is_trivially_move_assignable_v<T> is true, then IV has a trivial move assignment operator.
|
||
|
||
namespace std {template<class T, size_t N>class inplace_vector {public:// types:using value_type = T; using pointer = T*; using const_pointer = const T*; using reference = value_type&; using const_reference = const value_type&; using size_type = size_t; using difference_type = ptrdiff_t; using iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using const_iterator = *implementation-defined*; // see [[container.requirements]](container.requirements "23.2 Requirements")using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; // [[inplace.vector.cons]](#cons "23.3.16.2 Constructors"), construct/copy/destroyconstexpr inplace_vector() noexcept; constexpr explicit inplace_vector(size_type n); // freestanding-deletedconstexpr inplace_vector(size_type n, const T& value); // freestanding-deletedtemplate<class InputIterator>constexpr inplace_vector(InputIterator first, InputIterator last); // freestanding-deletedtemplate<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>constexpr inplace_vector(from_range_t, R&& rg); // freestanding-deletedconstexpr inplace_vector(const inplace_vector&); constexpr inplace_vector(inplace_vector&&)noexcept(N == 0 || is_nothrow_move_constructible_v<T>); constexpr inplace_vector(initializer_list<T> il); // freestanding-deletedconstexpr ~inplace_vector(); constexpr inplace_vector& operator=(const inplace_vector& other); constexpr inplace_vector& operator=(inplace_vector&& other)noexcept(N == 0 || (is_nothrow_move_assignable_v<T> && is_nothrow_move_constructible_v<T>)); constexpr inplace_vector& operator=(initializer_list<T>); // freestanding-deletedtemplate<class InputIterator>constexpr void assign(InputIterator first, InputIterator last); // freestanding-deletedtemplate<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>constexpr void assign_range(R&& rg); // freestanding-deletedconstexpr void assign(size_type n, const T& u); // freestanding-deletedconstexpr void assign(initializer_list<T> il); // freestanding-deleted// iteratorsconstexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr reverse_iterator rbegin() noexcept; constexpr const_reverse_iterator rbegin() const noexcept; constexpr reverse_iterator rend() noexcept; constexpr const_reverse_iterator rend() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; constexpr const_reverse_iterator crbegin() const noexcept; constexpr const_reverse_iterator crend() const noexcept; // [[inplace.vector.capacity]](#capacity "23.3.16.3 Capacity"), capacityconstexpr bool empty() const noexcept; constexpr size_type size() const noexcept; static constexpr size_type max_size() noexcept; static constexpr size_type capacity() noexcept; constexpr void resize(size_type sz); // freestanding-deletedconstexpr void resize(size_type sz, const T& c); // freestanding-deletedstatic constexpr void reserve(size_type n); // freestanding-deletedstatic constexpr void shrink_to_fit() noexcept; // element accessconstexpr reference operator[](size_type n); constexpr const_reference operator[](size_type n) const; constexpr reference at(size_type n); // freestanding-deletedconstexpr const_reference at(size_type n) const; // freestanding-deletedconstexpr reference front(); constexpr const_reference front() const; constexpr reference back(); constexpr const_reference back() const; // [[inplace.vector.data]](#data "23.3.16.4 Data"), data accessconstexpr T* data() noexcept; constexpr const T* data() const noexcept; // [[inplace.vector.modifiers]](#modifiers "23.3.16.5 Modifiers"), modifierstemplate<class... Args>constexpr reference emplace_back(Args&&... args); // freestanding-deletedconstexpr reference push_back(const T& x); // freestanding-deletedconstexpr reference push_back(T&& x); // freestanding-deletedtemplate<[*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); // freestanding-deletedconstexpr void pop_back(); 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); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>constexpr ranges::borrowed_iterator_t<R> try_append_range(R&& rg); template<class... Args>constexpr reference unchecked_emplace_back(Args&&... args); constexpr reference unchecked_push_back(const T& x); constexpr reference unchecked_push_back(T&& x); template<class... Args>constexpr iterator emplace(const_iterator position, Args&&... args); // freestanding-deletedconstexpr iterator insert(const_iterator position, const T& x); // freestanding-deletedconstexpr iterator insert(const_iterator position, T&& x); // freestanding-deletedconstexpr iterator insert(const_iterator position, size_type n, // freestanding-deletedconst T& x); template<class InputIterator>constexpr iterator insert(const_iterator position, // freestanding-deleted 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); // freestanding-deletedconstexpr iterator insert(const_iterator position, // freestanding-deleted initializer_list<T> il); constexpr iterator erase(const_iterator position); constexpr iterator erase(const_iterator first, const_iterator last); constexpr void swap(inplace_vector& x)noexcept(N == 0 || (is_nothrow_swappable_v<T> && is_nothrow_move_constructible_v<T>)); constexpr void clear() noexcept; friend constexpr bool operator==(const inplace_vector& x, const inplace_vector& y); friend constexpr *synth-three-way-result*<T>operator<=>(const inplace_vector& x, const inplace_vector& y); friend constexpr void swap(inplace_vector& x, inplace_vector& y)noexcept(N == 0 || (is_nothrow_swappable_v<T> && is_nothrow_move_constructible_v<T>)){ x.swap(y); }};}
|
||
|
||
#### [23.3.16.2](#cons) Constructors [[inplace.vector.cons]](inplace.vector.cons)
|
||
|
||
[ð](#lib:inplace_vector,constructor)
|
||
|
||
`constexpr explicit inplace_vector(size_type n);
|
||
`
|
||
|
||
[1](#cons-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10926)
|
||
|
||
*Preconditions*: T is *Cpp17DefaultInsertable* into inplace_vector[.](#cons-1.sentence-1)
|
||
|
||
[2](#cons-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10930)
|
||
|
||
*Effects*: Constructs an inplace_vector with n default-inserted elements[.](#cons-2.sentence-1)
|
||
|
||
[3](#cons-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10934)
|
||
|
||
*Complexity*: Linear in n[.](#cons-3.sentence-1)
|
||
|
||
[ð](#lib:inplace_vector,constructor_)
|
||
|
||
`constexpr inplace_vector(size_type n, const T& value);
|
||
`
|
||
|
||
[4](#cons-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10945)
|
||
|
||
*Preconditions*: T is *Cpp17CopyInsertable* into inplace_vector[.](#cons-4.sentence-1)
|
||
|
||
[5](#cons-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10949)
|
||
|
||
*Effects*: Constructs an inplace_vector with n copies of value[.](#cons-5.sentence-1)
|
||
|
||
[6](#cons-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10953)
|
||
|
||
*Complexity*: Linear in n[.](#cons-6.sentence-1)
|
||
|
||
[ð](#lib:inplace_vector,constructor__)
|
||
|
||
`template<class InputIterator>
|
||
constexpr inplace_vector(InputIterator first, InputIterator last);
|
||
`
|
||
|
||
[7](#cons-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10965)
|
||
|
||
*Effects*: Constructs an inplace_vector equal to the range [first, last)[.](#cons-7.sentence-1)
|
||
|
||
[8](#cons-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10969)
|
||
|
||
*Complexity*: Linear in distance(first, last)[.](#cons-8.sentence-1)
|
||
|
||
[ð](#lib:inplace_vector,constructor___)
|
||
|
||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>
|
||
constexpr inplace_vector(from_range_t, R&& rg);
|
||
`
|
||
|
||
[9](#cons-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10981)
|
||
|
||
*Effects*: Constructs an inplace_vector with
|
||
the elements of the range rg[.](#cons-9.sentence-1)
|
||
|
||
[10](#cons-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10986)
|
||
|
||
*Complexity*: Linear in ranges::distance(rg)[.](#cons-10.sentence-1)
|
||
|
||
#### [23.3.16.3](#capacity) Capacity [[inplace.vector.capacity]](inplace.vector.capacity)
|
||
|
||
[ð](#lib:capacity,inplace_vector)
|
||
|
||
`static constexpr size_type capacity() noexcept;
|
||
static constexpr size_type max_size() noexcept;
|
||
`
|
||
|
||
[1](#capacity-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11001)
|
||
|
||
*Returns*: N[.](#capacity-1.sentence-1)
|
||
|
||
[ð](#lib:resize,inplace_vector)
|
||
|
||
`constexpr void resize(size_type sz);
|
||
`
|
||
|
||
[2](#capacity-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11012)
|
||
|
||
*Preconditions*: T is *Cpp17DefaultInsertable* into inplace_vector[.](#capacity-2.sentence-1)
|
||
|
||
[3](#capacity-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11016)
|
||
|
||
*Effects*: If sz < size(),
|
||
erases the last size() - sz elements from the sequence[.](#capacity-3.sentence-1)
|
||
|
||
Otherwise,
|
||
appends sz - size() default-inserted elements to the sequence[.](#capacity-3.sentence-2)
|
||
|
||
[4](#capacity-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11024)
|
||
|
||
*Remarks*: If an exception is thrown, there are no effects on *this[.](#capacity-4.sentence-1)
|
||
|
||
[ð](#lib:resize,inplace_vector_)
|
||
|
||
`constexpr void resize(size_type sz, const T& c);
|
||
`
|
||
|
||
[5](#capacity-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11035)
|
||
|
||
*Preconditions*: T is *Cpp17CopyInsertable* into inplace_vector[.](#capacity-5.sentence-1)
|
||
|
||
[6](#capacity-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11039)
|
||
|
||
*Effects*: If sz < size(),
|
||
erases the last size() - sz elements from the sequence[.](#capacity-6.sentence-1)
|
||
|
||
Otherwise,
|
||
appends sz - size() copies of c to the sequence[.](#capacity-6.sentence-2)
|
||
|
||
[7](#capacity-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11047)
|
||
|
||
*Remarks*: If an exception is thrown, there are no effects on *this[.](#capacity-7.sentence-1)
|
||
|
||
[ð](#lib:reserve,inplace_vector)
|
||
|
||
`static constexpr void reserve(size_type n);
|
||
`
|
||
|
||
[8](#capacity-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11058)
|
||
|
||
*Effects*: None[.](#capacity-8.sentence-1)
|
||
|
||
[9](#capacity-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11062)
|
||
|
||
*Throws*: bad_alloc if n > capacity() is true[.](#capacity-9.sentence-1)
|
||
|
||
[ð](#lib:shrink_to_fit,inplace_vector)
|
||
|
||
`static constexpr void shrink_to_fit() noexcept;
|
||
`
|
||
|
||
[10](#capacity-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11073)
|
||
|
||
*Effects*: None[.](#capacity-10.sentence-1)
|
||
|
||
#### [23.3.16.4](#data) Data [[inplace.vector.data]](inplace.vector.data)
|
||
|
||
[ð](#lib:data,inplace_vector)
|
||
|
||
`constexpr T* data() noexcept;
|
||
constexpr const T* data() const noexcept;
|
||
`
|
||
|
||
[1](#data-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11087)
|
||
|
||
*Returns*: A pointer such that [data(), data() + size()) is a valid range[.](#data-1.sentence-1)
|
||
|
||
For a non-empty inplace_vector,data() == addressof(front()) is true[.](#data-1.sentence-2)
|
||
|
||
[2](#data-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11093)
|
||
|
||
*Complexity*: Constant time[.](#data-2.sentence-1)
|
||
|
||
#### [23.3.16.5](#modifiers) Modifiers [[inplace.vector.modifiers]](inplace.vector.modifiers)
|
||
|
||
[ð](#lib:insert,inplace_vector)
|
||
|
||
`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);
|
||
`
|
||
|
||
[1](#modifiers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11121)
|
||
|
||
Let n be the value of size() before this call for
|
||
the append_range overload, anddistance(begin, position) otherwise[.](#modifiers-1.sentence-1)
|
||
|
||
[2](#modifiers-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11126)
|
||
|
||
*Complexity*: Linear in the number of elements inserted plus
|
||
the distance to the end of the vector[.](#modifiers-2.sentence-1)
|
||
|
||
[3](#modifiers-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11131)
|
||
|
||
*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[.](#modifiers-3.sentence-1)
|
||
|
||
Otherwise,
|
||
if an exception is thrown, thensize() ⥠n and
|
||
elements in the range begin() + [0, n) are not modified[.](#modifiers-3.sentence-2)
|
||
|
||
[ð](#lib:push_back,inplace_vector)
|
||
|
||
`constexpr reference push_back(const T& x);
|
||
constexpr reference push_back(T&& x);
|
||
template<class... Args>
|
||
constexpr reference emplace_back(Args&&... args);
|
||
`
|
||
|
||
[4](#modifiers-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11157)
|
||
|
||
*Returns*: back()[.](#modifiers-4.sentence-1)
|
||
|
||
[5](#modifiers-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11161)
|
||
|
||
*Throws*: bad_alloc or
|
||
any exception thrown by the initialization of the inserted element[.](#modifiers-5.sentence-1)
|
||
|
||
[6](#modifiers-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11166)
|
||
|
||
*Complexity*: Constant[.](#modifiers-6.sentence-1)
|
||
|
||
[7](#modifiers-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11170)
|
||
|
||
*Remarks*: If an exception is thrown, there are no effects on *this[.](#modifiers-7.sentence-1)
|
||
|
||
[ð](#lib:try_emplace_back,inplace_vector)
|
||
|
||
`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);
|
||
`
|
||
|
||
[8](#modifiers-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11185)
|
||
|
||
Let vals denote a pack:
|
||
|
||
- [(8.1)](#modifiers-8.1)
|
||
|
||
std::forward<Args>(args)... for the first overload,
|
||
|
||
- [(8.2)](#modifiers-8.2)
|
||
|
||
x for the second overload,
|
||
|
||
- [(8.3)](#modifiers-8.3)
|
||
|
||
std::move(x) for the third overload[.](#modifiers-8.sentence-1)
|
||
|
||
[9](#modifiers-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11193)
|
||
|
||
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into inplace_vector from vals...[.](#modifiers-9.sentence-1)
|
||
|
||
[10](#modifiers-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11198)
|
||
|
||
*Effects*: If size() < capacity() is true,
|
||
appends an object of type T direct-non-list-initialized with vals...[.](#modifiers-10.sentence-1)
|
||
|
||
Otherwise, there are no effects[.](#modifiers-10.sentence-2)
|
||
|
||
[11](#modifiers-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11205)
|
||
|
||
*Returns*: nullptr if size() == capacity() is true,
|
||
otherwise addressof(back())[.](#modifiers-11.sentence-1)
|
||
|
||
[12](#modifiers-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11210)
|
||
|
||
*Throws*: Nothing unless an exception is thrown by the initialization of the inserted element[.](#modifiers-12.sentence-1)
|
||
|
||
[13](#modifiers-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11214)
|
||
|
||
*Complexity*: Constant[.](#modifiers-13.sentence-1)
|
||
|
||
[14](#modifiers-14)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11218)
|
||
|
||
*Remarks*: If an exception is thrown, there are no effects on *this[.](#modifiers-14.sentence-1)
|
||
|
||
[ð](#lib:try_append_range,inplace_vector)
|
||
|
||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<T> R>
|
||
constexpr ranges::borrowed_iterator_t<R> try_append_range(R&& rg);
|
||
`
|
||
|
||
[15](#modifiers-15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11230)
|
||
|
||
*Preconditions*: value_type is *Cpp17EmplaceConstructible* into inplace_vector from
|
||
|
||
*ranges::begin(rg)[.](#modifiers-15.sentence-2)
|
||
|
||
[16](#modifiers-16)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11235)
|
||
|
||
*Effects*: Appends copies of initial elements in rg before end(),
|
||
until all elements are inserted or size() == capacity() is true[.](#modifiers-16.sentence-1)
|
||
|
||
Each iterator in the range rg is dereferenced at most once[.](#modifiers-16.sentence-2)
|
||
|
||
[17](#modifiers-17)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11241)
|
||
|
||
*Returns*: An iterator pointing to the first element of rg that was not inserted into *this,
|
||
or ranges::end(rg) if no such element exists[.](#modifiers-17.sentence-1)
|
||
|
||
[18](#modifiers-18)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11247)
|
||
|
||
*Complexity*: Linear in the number of elements inserted[.](#modifiers-18.sentence-1)
|
||
|
||
[19](#modifiers-19)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11251)
|
||
|
||
*Remarks*: Let n be the value of size() prior to this call[.](#modifiers-19.sentence-1)
|
||
|
||
If an exception is thrown after the insertion of k elements, thensize() equals n+k,
|
||
elements in the range begin() + [0, n) are not modified, and
|
||
elements in the range begin() + [n, n+k) correspond to
|
||
the inserted elements[.](#modifiers-19.sentence-2)
|
||
|
||
[ð](#lib:unchecked_emplace_back,inplace_vector)
|
||
|
||
`template<class... Args>
|
||
constexpr reference unchecked_emplace_back(Args&&... args);
|
||
`
|
||
|
||
[20](#modifiers-20)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11268)
|
||
|
||
*Preconditions*: size() < capacity() is true[.](#modifiers-20.sentence-1)
|
||
|
||
[21](#modifiers-21)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11272)
|
||
|
||
*Effects*: Equivalent to:return *try_emplace_back(std::forward<Args>(args)...);
|
||
|
||
[ð](#lib:unchecked_push_back,inplace_vector)
|
||
|
||
`constexpr reference unchecked_push_back(const T& x);
|
||
constexpr reference unchecked_push_back(T&& x);
|
||
`
|
||
|
||
[22](#modifiers-22)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11285)
|
||
|
||
*Preconditions*: size() < capacity() is true[.](#modifiers-22.sentence-1)
|
||
|
||
[23](#modifiers-23)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11289)
|
||
|
||
*Effects*: Equivalent to:return *try_push_back(std::forward<decltype(x)>(x));
|
||
|
||
[ð](#lib:erase,inplace_vector)
|
||
|
||
`constexpr iterator erase(const_iterator position);
|
||
constexpr iterator erase(const_iterator first, const_iterator last);
|
||
constexpr void pop_back();
|
||
`
|
||
|
||
[24](#modifiers-24)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11304)
|
||
|
||
*Effects*: Invalidates iterators and references at or after the point of the erase[.](#modifiers-24.sentence-1)
|
||
|
||
[25](#modifiers-25)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11308)
|
||
|
||
*Throws*: Nothing unless an exception is thrown by
|
||
the assignment operator or move assignment operator of T[.](#modifiers-25.sentence-1)
|
||
|
||
[26](#modifiers-26)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11313)
|
||
|
||
*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[.](#modifiers-26.sentence-1)
|
||
|
||
#### [23.3.16.6](#erasure) Erasure [[inplace.vector.erasure]](inplace.vector.erasure)
|
||
|
||
[ð](#lib:erase,inplace_vector_)
|
||
|
||
`template<class T, size_t N, class U = T>
|
||
constexpr size_t erase(inplace_vector<T, N>& c, const U& value);
|
||
`
|
||
|
||
[1](#erasure-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11330)
|
||
|
||
*Effects*: Equivalent to:auto it = remove(c.begin(), c.end(), value);auto r = distance(it, c.end());
|
||
c.erase(it, c.end());return r;
|
||
|
||
[ð](#lib:erase_if,inplace_vector)
|
||
|
||
`template<class T, size_t N, class Predicate>
|
||
constexpr size_t erase_if(inplace_vector<T, N>& c, Predicate pred);
|
||
`
|
||
|
||
[2](#erasure-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11348)
|
||
|
||
*Effects*: Equivalent to:auto it = remove_if(c.begin(), c.end(), pred);auto r = distance(it, c.end());
|
||
c.erase(it, c.end());return r;
|