- tmp/tmpmun_5iyx/{from.md → to.md} +16 -249
tmp/tmpmun_5iyx/{from.md → to.md}
RENAMED
|
@@ -1,256 +1,23 @@
|
|
| 1 |
-
### General
|
| 2 |
|
| 3 |
-
|
| 4 |
-
and deallocation of these objects through constructors, destructors,
|
| 5 |
-
insert and erase operations.
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
`vector<int>` is itself linear. — *end example*]
|
| 13 |
-
|
| 14 |
-
For the components affected by this subclause that declare an
|
| 15 |
-
`allocator_type`, objects stored in these components shall be
|
| 16 |
-
constructed using the function
|
| 17 |
-
`allocator_traits<allocator_type>::rebind_traits<U>::{}construct` and
|
| 18 |
-
destroyed using the function
|
| 19 |
-
`allocator_traits<allocator_type>::rebind_traits<U>::{}destroy`
|
| 20 |
-
[[allocator.traits.members]], where `U` is either
|
| 21 |
-
`allocator_type::value_type` or an internal type used by the container.
|
| 22 |
-
These functions are called only for the container’s element type, not
|
| 23 |
-
for internal types used by the container.
|
| 24 |
-
|
| 25 |
-
[*Note 1*: This means, for example, that a node-based container might
|
| 26 |
-
need to construct nodes containing aligned buffers and call `construct`
|
| 27 |
-
to place the element into the buffer. — *end note*]
|
| 28 |
-
|
| 29 |
-
In Tables [[tab:container.req]], [[tab:container.rev.req]], and
|
| 30 |
-
[[tab:container.opt]] `X` denotes a container class containing objects
|
| 31 |
-
of type `T`, `a` and `b` denote values of type `X`, `i` and `j` denote
|
| 32 |
-
values of type (possibly const) `X::iterator`, `u` denotes an
|
| 33 |
-
identifier, `r` denotes a non-const value of type `X`, and `rv` denotes
|
| 34 |
-
a non-const rvalue of type `X`.
|
| 35 |
-
|
| 36 |
-
Those entries marked “(Note A)” or “(Note B)” have linear complexity for
|
| 37 |
-
`array` and have constant complexity for all other standard containers.
|
| 38 |
-
|
| 39 |
-
[*Note 2*: The algorithm `equal()` is defined in
|
| 40 |
-
[[algorithms]]. — *end note*]
|
| 41 |
-
|
| 42 |
-
The member function `size()` returns the number of elements in the
|
| 43 |
-
container. The number of elements is defined by the rules of
|
| 44 |
-
constructors, inserts, and erases.
|
| 45 |
-
|
| 46 |
-
`begin()`
|
| 47 |
-
|
| 48 |
-
returns an iterator referring to the first element in the container.
|
| 49 |
-
`end()` returns an iterator which is the past-the-end value for the
|
| 50 |
-
container. If the container is empty, then `begin() == end()`.
|
| 51 |
-
|
| 52 |
-
In the expressions
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
i <= j
|
| 59 |
-
i >= j
|
| 60 |
-
i > j
|
| 61 |
-
i <=> j
|
| 62 |
-
i - j
|
| 63 |
```
|
| 64 |
|
| 65 |
-
where `i` and `j` denote objects of a container’s `iterator` type,
|
| 66 |
-
either or both may be replaced by an object of the container’s
|
| 67 |
-
`const_iterator` type referring to the same element with no change in
|
| 68 |
-
semantics.
|
| 69 |
-
|
| 70 |
-
Unless otherwise specified, all containers defined in this clause obtain
|
| 71 |
-
memory using an allocator (see [[allocator.requirements]]).
|
| 72 |
-
|
| 73 |
-
[*Note 3*: In particular, containers and iterators do not store
|
| 74 |
-
references to allocated elements other than through the allocator’s
|
| 75 |
-
pointer type, i.e., as objects of type `P` or
|
| 76 |
-
`pointer_traits<P>::template rebind<unspecified>`, where `P` is
|
| 77 |
-
`allocator_traits<allocator_type>::pointer`. — *end note*]
|
| 78 |
-
|
| 79 |
-
Copy constructors for these container types obtain an allocator by
|
| 80 |
-
calling
|
| 81 |
-
`allocator_traits<allocator_type>::select_on_container_copy_construction`
|
| 82 |
-
on the allocator belonging to the container being copied. Move
|
| 83 |
-
constructors obtain an allocator by move construction from the allocator
|
| 84 |
-
belonging to the container being moved. Such move construction of the
|
| 85 |
-
allocator shall not exit via an exception. All other constructors for
|
| 86 |
-
these container types take a `const allocator_type&` argument.
|
| 87 |
-
|
| 88 |
-
[*Note 4*: If an invocation of a constructor uses the default value of
|
| 89 |
-
an optional allocator argument, then the allocator type must support
|
| 90 |
-
value-initialization. — *end note*]
|
| 91 |
-
|
| 92 |
-
A copy of this allocator is used for any memory allocation and element
|
| 93 |
-
construction performed, by these constructors and by all member
|
| 94 |
-
functions, during the lifetime of each container object or until the
|
| 95 |
-
allocator is replaced. The allocator may be replaced only via assignment
|
| 96 |
-
or `swap()`. Allocator replacement is performed by copy assignment, move
|
| 97 |
-
assignment, or swapping of the allocator only if
|
| 98 |
-
`allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value`,
|
| 99 |
-
`allocator_traits<allocator_type>::propagate_on_container_move_assignment::value`,
|
| 100 |
-
or
|
| 101 |
-
`allocator_traits<allocator_type>::propagate_on_container_swap::value`
|
| 102 |
-
is `true` within the implementation of the corresponding container
|
| 103 |
-
operation. In all container types defined in this Clause, the member
|
| 104 |
-
`get_allocator()` returns a copy of the allocator used to construct the
|
| 105 |
-
container or, if that allocator has been replaced, a copy of the most
|
| 106 |
-
recent replacement.
|
| 107 |
-
|
| 108 |
-
The expression `a.swap(b)`, for containers `a` and `b` of a standard
|
| 109 |
-
container type other than `array`, shall exchange the values of `a` and
|
| 110 |
-
`b` without invoking any move, copy, or swap operations on the
|
| 111 |
-
individual container elements. Lvalues of any `Compare`, `Pred`, or
|
| 112 |
-
`Hash` types belonging to `a` and `b` shall be swappable and shall be
|
| 113 |
-
exchanged by calling `swap` as described in [[swappable.requirements]].
|
| 114 |
-
If
|
| 115 |
-
`allocator_traits<allocator_type>::propagate_on_container_swap::value`
|
| 116 |
-
is `true`, then lvalues of type `allocator_type` shall be swappable and
|
| 117 |
-
the allocators of `a` and `b` shall also be exchanged by calling `swap`
|
| 118 |
-
as described in [[swappable.requirements]]. Otherwise, the allocators
|
| 119 |
-
shall not be swapped, and the behavior is undefined unless
|
| 120 |
-
`a.get_allocator() == b.get_allocator()`. Every iterator referring to an
|
| 121 |
-
element in one container before the swap shall refer to the same element
|
| 122 |
-
in the other container after the swap. It is unspecified whether an
|
| 123 |
-
iterator with value `a.end()` before the swap will have value `b.end()`
|
| 124 |
-
after the swap.
|
| 125 |
-
|
| 126 |
-
If the iterator type of a container belongs to the bidirectional or
|
| 127 |
-
random access iterator categories [[iterator.requirements]], the
|
| 128 |
-
container is called *reversible* and meets the additional requirements
|
| 129 |
-
in [[container.rev.req]].
|
| 130 |
-
|
| 131 |
-
Unless otherwise specified (see [[associative.reqmts.except]],
|
| 132 |
-
[[unord.req.except]], [[deque.modifiers]], and [[vector.modifiers]]) all
|
| 133 |
-
container types defined in this Clause meet the following additional
|
| 134 |
-
requirements:
|
| 135 |
-
|
| 136 |
-
- if an exception is thrown by an `insert()` or `emplace()` function
|
| 137 |
-
while inserting a single element, that function has no effects.
|
| 138 |
-
- if an exception is thrown by a `push_back()`, `push_front()`,
|
| 139 |
-
`emplace_back()`, or `emplace_front()` function, that function has no
|
| 140 |
-
effects.
|
| 141 |
-
- no `erase()`, `clear()`, `pop_back()` or `pop_front()` function throws
|
| 142 |
-
an exception.
|
| 143 |
-
- no copy constructor or assignment operator of a returned iterator
|
| 144 |
-
throws an exception.
|
| 145 |
-
- no `swap()` function throws an exception.
|
| 146 |
-
- no `swap()` function invalidates any references, pointers, or
|
| 147 |
-
iterators referring to the elements of the containers being swapped.
|
| 148 |
-
\[*Note 5*: The `end()` iterator does not refer to any element, so it
|
| 149 |
-
may be invalidated. — *end note*]
|
| 150 |
-
|
| 151 |
-
Unless otherwise specified (either explicitly or by defining a function
|
| 152 |
-
in terms of other functions), invoking a container member function or
|
| 153 |
-
passing a container as an argument to a library function shall not
|
| 154 |
-
invalidate iterators to, or change the values of, objects within that
|
| 155 |
-
container.
|
| 156 |
-
|
| 157 |
-
A *contiguous container* is a container whose member types `iterator`
|
| 158 |
-
and `const_iterator` meet the *Cpp17RandomAccessIterator* requirements
|
| 159 |
-
[[random.access.iterators]] and model `contiguous_iterator`
|
| 160 |
-
[[iterator.concept.contiguous]].
|
| 161 |
-
|
| 162 |
-
[[container.opt]] lists operations that are provided for some types of
|
| 163 |
-
containers but not others. Those containers for which the listed
|
| 164 |
-
operations are provided shall implement the semantics described in
|
| 165 |
-
[[container.opt]] unless otherwise stated. If the iterators passed to
|
| 166 |
-
`lexicographical_compare_three_way` meet the constexpr iterator
|
| 167 |
-
requirements [[iterator.requirements.general]] then the operations
|
| 168 |
-
described in [[container.opt]] are implemented by constexpr functions.
|
| 169 |
-
|
| 170 |
-
[*Note 6*: The algorithm `lexicographical_compare_three_way` is defined
|
| 171 |
-
in [[algorithms]]. — *end note*]
|
| 172 |
-
|
| 173 |
-
All of the containers defined in this Clause and in [[basic.string]]
|
| 174 |
-
except `array` meet the additional requirements of an allocator-aware
|
| 175 |
-
container, as described in [[container.alloc.req]].
|
| 176 |
-
|
| 177 |
-
Given an allocator type `A` and given a container type `X` having a
|
| 178 |
-
`value_type` identical to `T` and an `allocator_type` identical to
|
| 179 |
-
`allocator_traits<A>::rebind_alloc<T>` and given an lvalue `m` of type
|
| 180 |
-
`A`, a pointer `p` of type `T*`, an expression `v` of type (possibly
|
| 181 |
-
`const`) `T`, and an rvalue `rv` of type `T`, the following terms are
|
| 182 |
-
defined. If `X` is not allocator-aware, the terms below are defined as
|
| 183 |
-
if `A` were `allocator<T>` — no allocator object needs to be created and
|
| 184 |
-
user specializations of `allocator<T>` are not instantiated:
|
| 185 |
-
|
| 186 |
-
- `T` is **Cpp17DefaultInsertable* into `X`* means that the following
|
| 187 |
-
expression is well-formed:
|
| 188 |
-
``` cpp
|
| 189 |
-
allocator_traits<A>::construct(m, p)
|
| 190 |
-
```
|
| 191 |
-
- An element of `X` is *default-inserted* if it is initialized by
|
| 192 |
-
evaluation of the expression
|
| 193 |
-
``` cpp
|
| 194 |
-
allocator_traits<A>::construct(m, p)
|
| 195 |
-
```
|
| 196 |
-
|
| 197 |
-
where `p` is the address of the uninitialized storage for the element
|
| 198 |
-
allocated within `X`.
|
| 199 |
-
- `T` is **Cpp17MoveInsertable* into `X`* means that the following
|
| 200 |
-
expression is well-formed:
|
| 201 |
-
``` cpp
|
| 202 |
-
allocator_traits<A>::construct(m, p, rv)
|
| 203 |
-
```
|
| 204 |
-
|
| 205 |
-
and its evaluation causes the following postcondition to hold: The
|
| 206 |
-
value of `*p` is equivalent to the value of `rv` before the
|
| 207 |
-
evaluation.
|
| 208 |
-
\[*Note 7*: `rv` remains a valid object. Its state is
|
| 209 |
-
unspecified — *end note*]
|
| 210 |
-
- `T` is **Cpp17CopyInsertable* into `X`* means that, in addition to `T`
|
| 211 |
-
being *Cpp17MoveInsertable* into `X`, the following expression is
|
| 212 |
-
well-formed:
|
| 213 |
-
``` cpp
|
| 214 |
-
allocator_traits<A>::construct(m, p, v)
|
| 215 |
-
```
|
| 216 |
-
|
| 217 |
-
and its evaluation causes the following postcondition to hold: The
|
| 218 |
-
value of `v` is unchanged and is equivalent to `*p`.
|
| 219 |
-
- `T` is **Cpp17EmplaceConstructible* into `X` from `args`*, for zero or
|
| 220 |
-
more arguments `args`, means that the following expression is
|
| 221 |
-
well-formed:
|
| 222 |
-
``` cpp
|
| 223 |
-
allocator_traits<A>::construct(m, p, args)
|
| 224 |
-
```
|
| 225 |
-
- `T` is **Cpp17Erasable* from `X`* means that the following expression
|
| 226 |
-
is well-formed:
|
| 227 |
-
``` cpp
|
| 228 |
-
allocator_traits<A>::destroy(m, p)
|
| 229 |
-
```
|
| 230 |
-
|
| 231 |
-
[*Note 8*: A container calls
|
| 232 |
-
`allocator_traits<A>::construct(m, p, args)` to construct an element at
|
| 233 |
-
`p` using `args`, with `m == get_allocator()`. The default `construct`
|
| 234 |
-
in `allocator` will call `::new((void*)p) T(args)`, but specialized
|
| 235 |
-
allocators may choose a different definition. — *end note*]
|
| 236 |
-
|
| 237 |
-
In [[container.alloc.req]], `X` denotes an allocator-aware container
|
| 238 |
-
class with a `value_type` of `T` using allocator of type `A`, `u`
|
| 239 |
-
denotes a variable, `a` and `b` denote non-const lvalues of type `X`,
|
| 240 |
-
`t` denotes an lvalue or a const rvalue of type `X`, `rv` denotes a
|
| 241 |
-
non-const rvalue of type `X`, and `m` is a value of type `A`.
|
| 242 |
-
|
| 243 |
-
The behavior of certain container member functions and deduction guides
|
| 244 |
-
depends on whether types qualify as input iterators or allocators. The
|
| 245 |
-
extent to which an implementation determines that a type cannot be an
|
| 246 |
-
input iterator is unspecified, except that as a minimum integral types
|
| 247 |
-
shall not qualify as input iterators. Likewise, the extent to which an
|
| 248 |
-
implementation determines that a type cannot be an allocator is
|
| 249 |
-
unspecified, except that as a minimum a type `A` shall not qualify as an
|
| 250 |
-
allocator unless it meets both of the following conditions:
|
| 251 |
-
|
| 252 |
-
- The *qualified-id* `A::value_type` is valid and denotes a type
|
| 253 |
-
[[temp.deduct]].
|
| 254 |
-
- The expression `declval<A&>().allocate(size_t{})` is well-formed when
|
| 255 |
-
treated as an unevaluated operand.
|
| 256 |
-
|
|
|
|
| 1 |
+
#### General <a id="container.requirements.general">[[container.requirements.general]]</a>
|
| 2 |
|
| 3 |
+
In subclause [[container.gen.reqmts]],
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
- `X` denotes a container class containing objects of type `T`,
|
| 6 |
+
- `a` denotes a value of type `X`,
|
| 7 |
+
- `b` and `c` denote values of type (possibly const) `X`,
|
| 8 |
+
- `i` and `j` denote values of type (possibly const) `X::iterator`,
|
| 9 |
+
- `u` denotes an identifier,
|
| 10 |
+
- `v` denotes an lvalue of type (possibly const) `X` or an rvalue of
|
| 11 |
+
type `const X`,
|
| 12 |
+
- `s` and `t` denote non-const lvalues of type `X`, and
|
| 13 |
+
- `rv` denotes a non-const rvalue of type `X`.
|
| 14 |
|
| 15 |
+
The following exposition-only concept is used in the definition of
|
| 16 |
+
containers:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
+
template<class R, class T>
|
| 20 |
+
concept container-compatible-range = // exposition only
|
| 21 |
+
ranges::input_range<R> && convertible_to<ranges::range_reference_t<R>, T>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
```
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|