From Jason Turner

[container.requirements.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpjhgut_ij/{from.md → to.md} +77 -32
tmp/tmpjhgut_ij/{from.md → to.md} RENAMED
@@ -19,15 +19,16 @@ function and destroyed using the
19
  container’s element type, not for internal types used by the container.
20
  This means, for example, that a node-based container might need to
21
  construct nodes containing aligned buffers and call `construct` to place
22
  the element into the buffer.
23
 
24
- In Tables  [[tab:containers.container.requirements]] and
25
- [[tab:containers.reversible.requirements]], `X` denotes a container
26
- class containing objects of type `T`, `a` and `b` denote values of type
27
- `X`, `u` denotes an identifier, `r` denotes a non-const value of type
28
- `X`, and `rv` denotes a non-const rvalue of type `X`.
 
29
 
30
  Notes: the algorithm `equal()` is defined in Clause  [[algorithms]].
31
  Those entries marked “(Note A)” or “(Note B)” have linear complexity for
32
  `array` and have constant complexity for all other standard containers.
33
 
@@ -39,28 +40,44 @@ constructors, inserts, and erases.
39
 
40
  returns an iterator referring to the first element in the container.
41
  `end()` returns an iterator which is the past-the-end value for the
42
  container. If the container is empty, then `begin() == end()`;
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  Unless otherwise specified, all containers defined in this clause obtain
45
  memory using an allocator (see  [[allocator.requirements]]). Copy
46
  constructors for these container types obtain an allocator by calling
47
  `allocator_traits<allocator_type>::select_on_container_copy_construction`
48
- on their first parameters. Move constructors obtain an allocator by move
49
- construction from the allocator belonging to the container being moved.
50
- Such move construction of the allocator shall not exit via an exception.
51
- All other constructors for these container types take an `Allocator&`
52
- argument ([[allocator.requirements]]), an allocator whose value type is
53
- the same as the container’s value type. If an invocation of a
54
- constructor uses the default value of an optional allocator argument,
55
- then the `Allocator` type must support value initialization. A copy of
56
- this allocator is used for any memory allocation performed, by these
57
- constructors and by all member functions, during the lifetime of each
58
- container object or until the allocator is replaced. The allocator may
59
- be replaced only via assignment or `swap()`. Allocator replacement is
60
- performed by copy assignment, move assignment, or swapping of the
61
- allocator only if
62
  `allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value`,
63
  `allocator_traits<allocator_type>::propagate_on_container_move_assignment::value`,
64
  or
65
  `allocator_traits<allocator_type>::propagate_on_container_swap::value`
66
  is true within the implementation of the corresponding container
@@ -99,12 +116,13 @@ Unless otherwise specified (see  [[associative.reqmts.except]],
99
  container types defined in this Clause meet the following additional
100
  requirements:
101
 
102
  - if an exception is thrown by an `insert()` or `emplace()` function
103
  while inserting a single element, that function has no effects.
104
- - if an exception is thrown by a `push_back()` or `push_front()`
105
- function, that function has no effects.
 
106
  - no `erase()`, `clear()`, `pop_back()` or `pop_front()` function throws
107
  an exception.
108
  - no copy constructor or assignment operator of a returned iterator
109
  throws an exception.
110
  - no `swap()` function throws an exception.
@@ -132,29 +150,56 @@ All of the containers defined in this Clause and in ([[basic.string]])
132
  except `array` meet the additional requirements of an allocator-aware
133
  container, as described in Table  [[tab:containers.allocatoraware]].
134
 
135
  Given a container type `X` having an `allocator_type` identical to `A`
136
  and a `value_type` identical to `T` and given an lvalue `m` of type `A`,
137
- a pointer `p` of type `T*`, an expression `v` of type `T`, and an rvalue
138
- `rv` of type `T`, the following terms are defined. (If `X` is not
139
- allocator-aware, the terms below are defined as if `A` were
140
- `std::allocator<T>`.)
 
141
 
142
- - `T` is *`CopyInsertable` into `X`* means that the following expression
143
- is well-formed:
144
  ``` cpp
145
- allocator_traits<A>::construct(m, p, v);
146
  ```
 
 
 
 
 
 
 
 
147
  - `T` is *`MoveInsertable` into `X`* means that the following expression
148
  is well-formed:
149
  ``` cpp
150
- allocator_traits<A>::construct(m, p, rv);
151
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  - `T` is *`EmplaceConstructible` into `X` from `args`*, for zero or more
153
  arguments `args`, means that the following expression is well-formed:
154
  ``` cpp
155
- allocator_traits<A>::construct(m, p, args);
 
 
 
 
 
156
  ```
157
 
158
  A container calls `allocator_traits<A>::construct(m, p, args)` to
159
  construct an element at `p` using `args`. The default `construct` in
160
  `std::allocator` will call `::new((void*)p) T(args)`, but specialized
@@ -162,8 +207,8 @@ allocators may choose a different definition.
162
 
163
  In Table  [[tab:containers.allocatoraware]], `X` denotes an
164
  allocator-aware container class with a `value_type` of `T` using
165
  allocator of type `A`, `u` denotes a variable, `a` and `b` denote
166
  non-const lvalues of type `X`, `t` denotes an lvalue or a const rvalue
167
- of type X``, `rv` denotes a non-const rvalue of type `X`, `m` is a value
168
- of type `A`, and `Q` is an allocator type.
169
 
 
19
  container’s element type, not for internal types used by the container.
20
  This means, for example, that a node-based container might need to
21
  construct nodes containing aligned buffers and call `construct` to place
22
  the element into the buffer.
23
 
24
+ In Tables  [[tab:containers.container.requirements]],
25
+ [[tab:containers.reversible.requirements]], and
26
+ [[tab:containers.optional.operations]] `X` denotes a container class
27
+ containing objects of type `T`, `a` and `b` denote values of type `X`,
28
+ `u` denotes an identifier, `r` denotes a non-const value of type `X`,
29
+ and `rv` denotes a non-const rvalue of type `X`.
30
 
31
  Notes: the algorithm `equal()` is defined in Clause  [[algorithms]].
32
  Those entries marked “(Note A)” or “(Note B)” have linear complexity for
33
  `array` and have constant complexity for all other standard containers.
34
 
 
40
 
41
  returns an iterator referring to the first element in the container.
42
  `end()` returns an iterator which is the past-the-end value for the
43
  container. If the container is empty, then `begin() == end()`;
44
 
45
+ In the expressions
46
+
47
+ ``` cpp
48
+ i == j
49
+ i != j
50
+ i < j
51
+ i <= j
52
+ i >= j
53
+ i > j
54
+ i - j
55
+ ```
56
+
57
+ where `i` and `j` denote objects of a container’s `iterator` type,
58
+ either or both may be replaced by an object of the container’s
59
+ `const_iterator` type referring to the same element with no change in
60
+ semantics.
61
+
62
  Unless otherwise specified, all containers defined in this clause obtain
63
  memory using an allocator (see  [[allocator.requirements]]). Copy
64
  constructors for these container types obtain an allocator by calling
65
  `allocator_traits<allocator_type>::select_on_container_copy_construction`
66
+ on the allocator belonging to the container being copied. Move
67
+ constructors obtain an allocator by move construction from the allocator
68
+ belonging to the container being moved. Such move construction of the
69
+ allocator shall not exit via an exception. All other constructors for
70
+ these container types take a `const allocator_type&` argument. If an
71
+ invocation of a constructor uses the default value of an optional
72
+ allocator argument, then the `Allocator` type must support value
73
+ initialization. A copy of this allocator is used for any memory
74
+ allocation performed, by these constructors and by all member functions,
75
+ during the lifetime of each container object or until the allocator is
76
+ replaced. The allocator may be replaced only via assignment or `swap()`.
77
+ Allocator replacement is performed by copy assignment, move assignment,
78
+ or swapping of the allocator only if
 
79
  `allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value`,
80
  `allocator_traits<allocator_type>::propagate_on_container_move_assignment::value`,
81
  or
82
  `allocator_traits<allocator_type>::propagate_on_container_swap::value`
83
  is true within the implementation of the corresponding container
 
116
  container types defined in this Clause meet the following additional
117
  requirements:
118
 
119
  - if an exception is thrown by an `insert()` or `emplace()` function
120
  while inserting a single element, that function has no effects.
121
+ - if an exception is thrown by a `push_back()`, `push_front()`,
122
+ `emplace_back()`, or `emplace_front()` function, that function has no
123
+ effects.
124
  - no `erase()`, `clear()`, `pop_back()` or `pop_front()` function throws
125
  an exception.
126
  - no copy constructor or assignment operator of a returned iterator
127
  throws an exception.
128
  - no `swap()` function throws an exception.
 
150
  except `array` meet the additional requirements of an allocator-aware
151
  container, as described in Table  [[tab:containers.allocatoraware]].
152
 
153
  Given a container type `X` having an `allocator_type` identical to `A`
154
  and a `value_type` identical to `T` and given an lvalue `m` of type `A`,
155
+ a pointer `p` of type `T*`, an expression `v` of type (possibly const)
156
+ `T`, and an rvalue `rv` of type `T`, the following terms are defined. If
157
+ `X` is not allocator-aware, the terms below are defined as if `A` were
158
+ `std::allocator<T>` — no allocator object needs to be created and user
159
+ specializations of `std::allocator<T>` are not instantiated:
160
 
161
+ - `T` is *`DefaultInsertable` into `X`* means that the following
162
+ expression is well-formed:
163
  ``` cpp
164
+ allocator_traits<A>::construct(m, p)
165
  ```
166
+ - An element of `X` is *default-inserted* if it is initialized by
167
+ evaluation of the expression
168
+ ``` cpp
169
+ allocator_traits<A>::construct(m, p)
170
+ ```
171
+
172
+ where `p` is the address of the uninitialized storage for the element
173
+ allocated within `X`.
174
  - `T` is *`MoveInsertable` into `X`* means that the following expression
175
  is well-formed:
176
  ``` cpp
177
+ allocator_traits<A>::construct(m, p, rv)
178
  ```
179
+
180
+ and its evaluation causes the following postcondition to hold: The
181
+ value of `*p` is equivalent to the value of `rv` before the
182
+ evaluation. rv remains a valid object. Its state is unspecified
183
+ - `T` is *`CopyInsertable` into `X`* means that, in addition to `T`
184
+ being `MoveInsertable` into `X`, the following expression is
185
+ well-formed:
186
+ ``` cpp
187
+ allocator_traits<A>::construct(m, p, v)
188
+ ```
189
+
190
+ and its evaluation causes the following postcondition to hold: The
191
+ value of `v` is unchanged and is equivalent to `*p`.
192
  - `T` is *`EmplaceConstructible` into `X` from `args`*, for zero or more
193
  arguments `args`, means that the following expression is well-formed:
194
  ``` cpp
195
+ allocator_traits<A>::construct(m, p, args)
196
+ ```
197
+ - `T` is *`Erasable` from `X`* means that the following expression is
198
+ well-formed:
199
+ ``` cpp
200
+ allocator_traits<A>::destroy(m, p)
201
  ```
202
 
203
  A container calls `allocator_traits<A>::construct(m, p, args)` to
204
  construct an element at `p` using `args`. The default `construct` in
205
  `std::allocator` will call `::new((void*)p) T(args)`, but specialized
 
207
 
208
  In Table  [[tab:containers.allocatoraware]], `X` denotes an
209
  allocator-aware container class with a `value_type` of `T` using
210
  allocator of type `A`, `u` denotes a variable, `a` and `b` denote
211
  non-const lvalues of type `X`, `t` denotes an lvalue or a const rvalue
212
+ of type `X`, `rv` denotes a non-const rvalue of type `X`, and `m` is a
213
+ value of type `A`.
214