85 lines
9.5 KiB
Markdown
85 lines
9.5 KiB
Markdown
[inplace.vector.overview]
|
||
|
||
# 23 Containers library [[containers]](./#containers)
|
||
|
||
## 23.3 Sequence containers [[sequences]](sequences#inplace.vector.overview)
|
||
|
||
### 23.3.16 Class template inplace_vector [[inplace.vector]](inplace.vector#overview)
|
||
|
||
#### 23.3.16.1 Overview [inplace.vector.overview]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10713)
|
||
|
||
An inplace_vector is a contiguous container[.](#1.sentence-1)
|
||
|
||
Its capacity is fixed and
|
||
its elements are stored within the inplace_vector object itself[.](#1.sentence-2)
|
||
|
||
[2](#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"))[.](#2.sentence-1)
|
||
|
||
The exceptions are thepush_front,prepend_range,pop_front, andemplace_front member functions, which are not provided[.](#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[.](#2.sentence-3)
|
||
|
||
[3](#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[.](#3.sentence-1)
|
||
|
||
[4](#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[.](#4.sentence-1)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L10748)
|
||
|
||
Let IV denote a specialization of inplace_vector<T, N>[.](#5.sentence-1)
|
||
|
||
If N is zero, thenIV is trivially copyable and empty, andstd::is_trivially_default_constructible_v<IV> is true[.](#5.sentence-2)
|
||
|
||
Otherwise:
|
||
|
||
- [(5.1)](#5.1)
|
||
|
||
If is_trivially_copy_constructible_v<T> is true, thenIV has a trivial copy constructor[.](#5.1.sentence-1)
|
||
|
||
- [(5.2)](#5.2)
|
||
|
||
If is_trivially_move_constructible_v<T> is true, thenIV has a trivial move constructor[.](#5.2.sentence-1)
|
||
|
||
- [(5.3)](#5.3)
|
||
|
||
If is_trivially_destructible_v<T> is true, then:
|
||
* [(5.3.1)](#5.3.1)
|
||
|
||
IV has a trivial destructor.
|
||
|
||
* [(5.3.2)](#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)](#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]](inplace.vector.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]](inplace.vector.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]](inplace.vector.data "23.3.16.4 Data"), data accessconstexpr T* data() noexcept; constexpr const T* data() const noexcept; // [[inplace.vector.modifiers]](inplace.vector.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); }};}
|