tmp/tmpyk5opiu7/{from.md → to.md}
RENAMED
|
@@ -14,31 +14,31 @@ linear complexity, even though the complexity of copying each contained
|
|
| 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]]
|
| 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:
|
| 30 |
-
[[tab:
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 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.
|
|
@@ -56,10 +56,11 @@ i == j
|
|
| 56 |
i != j
|
| 57 |
i < j
|
| 58 |
i <= j
|
| 59 |
i >= j
|
| 60 |
i > j
|
|
|
|
| 61 |
i - j
|
| 62 |
```
|
| 63 |
|
| 64 |
where `i` and `j` denote objects of a container’s `iterator` type,
|
| 65 |
either or both may be replaced by an object of the container’s
|
|
@@ -83,11 +84,11 @@ constructors obtain an allocator by move construction from the allocator
|
|
| 83 |
belonging to the container being moved. Such move construction of the
|
| 84 |
allocator shall not exit via an exception. All other constructors for
|
| 85 |
these container types take a `const allocator_type&` argument.
|
| 86 |
|
| 87 |
[*Note 4*: If an invocation of a constructor uses the default value of
|
| 88 |
-
an optional allocator argument, then the
|
| 89 |
value-initialization. — *end note*]
|
| 90 |
|
| 91 |
A copy of this allocator is used for any memory allocation and element
|
| 92 |
construction performed, by these constructors and by all member
|
| 93 |
functions, during the lifetime of each container object or until the
|
|
@@ -121,13 +122,13 @@ element in one container before the swap shall refer to the same element
|
|
| 121 |
in the other container after the swap. It is unspecified whether an
|
| 122 |
iterator with value `a.end()` before the swap will have value `b.end()`
|
| 123 |
after the swap.
|
| 124 |
|
| 125 |
If the iterator type of a container belongs to the bidirectional or
|
| 126 |
-
random access iterator categories
|
| 127 |
-
container is called *reversible* and
|
| 128 |
-
|
| 129 |
|
| 130 |
Unless otherwise specified (see [[associative.reqmts.except]],
|
| 131 |
[[unord.req.except]], [[deque.modifiers]], and [[vector.modifiers]]) all
|
| 132 |
container types defined in this Clause meet the following additional
|
| 133 |
requirements:
|
|
@@ -151,38 +152,40 @@ Unless otherwise specified (either explicitly or by defining a function
|
|
| 151 |
in terms of other functions), invoking a container member function or
|
| 152 |
passing a container as an argument to a library function shall not
|
| 153 |
invalidate iterators to, or change the values of, objects within that
|
| 154 |
container.
|
| 155 |
|
| 156 |
-
A *contiguous container* is a container
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
[[iterator.
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
| 166 |
|
| 167 |
-
[*Note 6*: The algorithm `
|
| 168 |
-
|
| 169 |
|
| 170 |
All of the containers defined in this Clause and in [[basic.string]]
|
| 171 |
except `array` meet the additional requirements of an allocator-aware
|
| 172 |
-
container, as described in
|
| 173 |
|
| 174 |
Given an allocator type `A` and given a container type `X` having a
|
| 175 |
`value_type` identical to `T` and an `allocator_type` identical to
|
| 176 |
`allocator_traits<A>::rebind_alloc<T>` and given an lvalue `m` of type
|
| 177 |
`A`, a pointer `p` of type `T*`, an expression `v` of type (possibly
|
| 178 |
`const`) `T`, and an rvalue `rv` of type `T`, the following terms are
|
| 179 |
defined. If `X` is not allocator-aware, the terms below are defined as
|
| 180 |
if `A` were `allocator<T>` — no allocator object needs to be created and
|
| 181 |
user specializations of `allocator<T>` are not instantiated:
|
| 182 |
|
| 183 |
-
- `T` is *
|
| 184 |
expression is well-formed:
|
| 185 |
``` cpp
|
| 186 |
allocator_traits<A>::construct(m, p)
|
| 187 |
```
|
| 188 |
- An element of `X` is *default-inserted* if it is initialized by
|
|
@@ -191,63 +194,63 @@ user specializations of `allocator<T>` are not instantiated:
|
|
| 191 |
allocator_traits<A>::construct(m, p)
|
| 192 |
```
|
| 193 |
|
| 194 |
where `p` is the address of the uninitialized storage for the element
|
| 195 |
allocated within `X`.
|
| 196 |
-
- `T` is *
|
| 197 |
-
is well-formed:
|
| 198 |
``` cpp
|
| 199 |
allocator_traits<A>::construct(m, p, rv)
|
| 200 |
```
|
| 201 |
|
| 202 |
and its evaluation causes the following postcondition to hold: The
|
| 203 |
value of `*p` is equivalent to the value of `rv` before the
|
| 204 |
evaluation.
|
| 205 |
\[*Note 7*: `rv` remains a valid object. Its state is
|
| 206 |
unspecified — *end note*]
|
| 207 |
-
- `T` is *
|
| 208 |
-
being
|
| 209 |
well-formed:
|
| 210 |
``` cpp
|
| 211 |
allocator_traits<A>::construct(m, p, v)
|
| 212 |
```
|
| 213 |
|
| 214 |
and its evaluation causes the following postcondition to hold: The
|
| 215 |
value of `v` is unchanged and is equivalent to `*p`.
|
| 216 |
-
- `T` is *
|
| 217 |
-
arguments `args`, means that the following expression is
|
|
|
|
| 218 |
``` cpp
|
| 219 |
allocator_traits<A>::construct(m, p, args)
|
| 220 |
```
|
| 221 |
-
- `T` is *
|
| 222 |
-
well-formed:
|
| 223 |
``` cpp
|
| 224 |
allocator_traits<A>::destroy(m, p)
|
| 225 |
```
|
| 226 |
|
| 227 |
[*Note 8*: A container calls
|
| 228 |
`allocator_traits<A>::construct(m, p, args)` to construct an element at
|
| 229 |
`p` using `args`, with `m == get_allocator()`. The default `construct`
|
| 230 |
in `allocator` will call `::new((void*)p) T(args)`, but specialized
|
| 231 |
allocators may choose a different definition. — *end note*]
|
| 232 |
|
| 233 |
-
In
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
value of type `A`.
|
| 239 |
|
| 240 |
The behavior of certain container member functions and deduction guides
|
| 241 |
depends on whether types qualify as input iterators or allocators. The
|
| 242 |
extent to which an implementation determines that a type cannot be an
|
| 243 |
input iterator is unspecified, except that as a minimum integral types
|
| 244 |
shall not qualify as input iterators. Likewise, the extent to which an
|
| 245 |
implementation determines that a type cannot be an allocator is
|
| 246 |
unspecified, except that as a minimum a type `A` shall not qualify as an
|
| 247 |
-
allocator unless it
|
| 248 |
|
| 249 |
-
- The *qualified-id* `A::value_type` is valid and denotes a type
|
| 250 |
-
[[temp.deduct]]
|
| 251 |
- The expression `declval<A&>().allocate(size_t{})` is well-formed when
|
| 252 |
treated as an unevaluated operand.
|
| 253 |
|
|
|
|
| 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.
|
|
|
|
| 56 |
i != j
|
| 57 |
i < j
|
| 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
|
|
|
|
| 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
|
|
|
|
| 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:
|
|
|
|
| 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
|
|
|
|
| 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 |
|