From Jason Turner

[vector]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfmrmpaox/{from.md → to.md} +57 -31
tmp/tmpfmrmpaox/{from.md → to.md} RENAMED
@@ -5,21 +5,21 @@
5
  A `vector` is a sequence container that supports (amortized) constant
6
  time insert and erase operations at the end; insert and erase in the
7
  middle take linear time. Storage management is handled automatically,
8
  though hints can be given to improve efficiency.
9
 
10
- A `vector` meets all of the requirements of a container and of a
11
- reversible container (given in two tables in 
12
- [[container.requirements]]), of a sequence container, including most of
13
- the optional sequence container requirements [[sequence.reqmts]], of an
14
- allocator-aware container ([[container.alloc.req]]), and, for an
15
- element type other than `bool`, of a contiguous container
16
- [[container.requirements.general]]. The exceptions are the `push_front`,
17
- `pop_front`, and `emplace_front` member functions, which are not
18
- provided. Descriptions are provided here only for operations on `vector`
19
- that are not described in one of these tables or for operations where
20
- there is additional semantic information.
21
 
22
  The types `iterator` and `const_iterator` meet the constexpr iterator
23
  requirements [[iterator.requirements.general]].
24
 
25
  ``` cpp
@@ -32,12 +32,12 @@ namespace std {
32
  using allocator_type = Allocator;
33
  using pointer = typename allocator_traits<Allocator>::pointer;
34
  using const_pointer = typename allocator_traits<Allocator>::const_pointer;
35
  using reference = value_type&;
36
  using const_reference = const value_type&;
37
- using size_type = implementation-defined; // see [container.requirements]
38
- using difference_type = implementation-defined; // see [container.requirements]
39
  using iterator = implementation-defined // type of vector::iterator; // see [container.requirements]
40
  using const_iterator = implementation-defined // type of vector::const_iterator; // see [container.requirements]
41
  using reverse_iterator = std::reverse_iterator<iterator>;
42
  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
43
 
@@ -46,23 +46,27 @@ namespace std {
46
  constexpr explicit vector(const Allocator&) noexcept;
47
  constexpr explicit vector(size_type n, const Allocator& = Allocator());
48
  constexpr vector(size_type n, const T& value, const Allocator& = Allocator());
49
  template<class InputIterator>
50
  constexpr vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
 
 
51
  constexpr vector(const vector& x);
52
  constexpr vector(vector&&) noexcept;
53
- constexpr vector(const vector&, const Allocator&);
54
- constexpr vector(vector&&, const Allocator&);
55
  constexpr vector(initializer_list<T>, const Allocator& = Allocator());
56
  constexpr ~vector();
57
  constexpr vector& operator=(const vector& x);
58
  constexpr vector& operator=(vector&& x)
59
  noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
60
  allocator_traits<Allocator>::is_always_equal::value);
61
  constexpr vector& operator=(initializer_list<T>);
62
  template<class InputIterator>
63
  constexpr void assign(InputIterator first, InputIterator last);
 
 
64
  constexpr void assign(size_type n, const T& u);
65
  constexpr void assign(initializer_list<T>);
66
  constexpr allocator_type get_allocator() const noexcept;
67
 
68
  // iterators
@@ -106,19 +110,23 @@ namespace std {
106
 
107
  // [vector.modifiers], modifiers
108
  template<class... Args> constexpr reference emplace_back(Args&&... args);
109
  constexpr void push_back(const T& x);
110
  constexpr void push_back(T&& x);
 
 
111
  constexpr void pop_back();
112
 
113
  template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
114
  constexpr iterator insert(const_iterator position, const T& x);
115
  constexpr iterator insert(const_iterator position, T&& x);
116
  constexpr iterator insert(const_iterator position, size_type n, const T& x);
117
  template<class InputIterator>
118
  constexpr iterator insert(const_iterator position,
119
  InputIterator first, InputIterator last);
 
 
120
  constexpr iterator insert(const_iterator position, initializer_list<T> il);
121
  constexpr iterator erase(const_iterator position);
122
  constexpr iterator erase(const_iterator first, const_iterator last);
123
  constexpr void swap(vector&)
124
  noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
@@ -128,23 +136,22 @@ namespace std {
128
 
129
  template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
130
  vector(InputIterator, InputIterator, Allocator = Allocator())
131
  -> vector<iter-value-type<InputIterator>, Allocator>;
132
 
133
- // swap
134
- template<class T, class Allocator>
135
- constexpr void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
136
- noexcept(noexcept(x.swap(y)));
137
  }
138
  ```
139
 
140
  An incomplete type `T` may be used when instantiating `vector` if the
141
  allocator meets the allocator completeness requirements
142
  [[allocator.requirements.completeness]]. `T` shall be complete before
143
  any member of the resulting specialization of `vector` is referenced.
144
 
145
- #### Constructors, copy, and assignment <a id="vector.cons">[[vector.cons]]</a>
146
 
147
  ``` cpp
148
  constexpr explicit vector(const Allocator&) noexcept;
149
  ```
150
 
@@ -185,12 +192,27 @@ template<class InputIterator>
185
  using the specified allocator.
186
 
187
  *Complexity:* Makes only N calls to the copy constructor of `T` (where N
188
  is the distance between `first` and `last`) and no reallocations if
189
  iterators `first` and `last` are of forward, bidirectional, or random
190
- access categories. It makes order `N` calls to the copy constructor of
191
- `T` and order log N reallocations if they are just input iterators.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
  #### Capacity <a id="vector.capacity">[[vector.capacity]]</a>
194
 
195
  ``` cpp
196
  constexpr size_type capacity() const noexcept;
@@ -214,15 +236,15 @@ size, so that it can manage the storage allocation accordingly. After
214
  `capacity()` otherwise. Reallocation happens at this point if and only
215
  if the current capacity is less than the argument of `reserve()`. If an
216
  exception is thrown other than by the move constructor of a
217
  non-*Cpp17CopyInsertable* type, there are no effects.
218
 
 
 
219
  *Complexity:* It does not change the size of the sequence and takes at
220
  most linear time in the size of the sequence.
221
 
222
- *Throws:* `length_error` if `n > max_size()`.[^4]
223
-
224
  *Remarks:* Reallocation invalidates all the references, pointers, and
225
  iterators referring to the elements in the sequence, as well as the
226
  past-the-end iterator.
227
 
228
  [*Note 1*: If no reallocation happens, they remain
@@ -313,18 +335,26 @@ range. For a non-empty vector, `data()` `==` `addressof(front())`.
313
  constexpr iterator insert(const_iterator position, const T& x);
314
  constexpr iterator insert(const_iterator position, T&& x);
315
  constexpr iterator insert(const_iterator position, size_type n, const T& x);
316
  template<class InputIterator>
317
  constexpr iterator insert(const_iterator position, InputIterator first, InputIterator last);
 
 
318
  constexpr iterator insert(const_iterator position, initializer_list<T>);
319
 
320
  template<class... Args> constexpr reference emplace_back(Args&&... args);
321
  template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
322
  constexpr void push_back(const T& x);
323
  constexpr void push_back(T&& x);
 
 
324
  ```
325
 
 
 
 
 
326
  *Remarks:* Causes reallocation if the new size is greater than the old
327
  capacity. Reallocation invalidates all the references, pointers, and
328
  iterators referring to the elements in the sequence, as well as the
329
  past-the-end iterator. If no reallocation happens, then references,
330
  pointers, and iterators before the insertion point remain valid but
@@ -336,31 +366,27 @@ no effects. If an exception is thrown while inserting a single element
336
  at the end and `T` is *Cpp17CopyInsertable* or
337
  `is_nothrow_move_constructible_v<T>` is `true`, there are no effects.
338
  Otherwise, if an exception is thrown by the move constructor of a
339
  non-*Cpp17CopyInsertable* `T`, the effects are unspecified.
340
 
341
- *Complexity:* If reallocation happens, linear in the number of elements
342
- of the resulting vector; otherwise, linear in the number of elements
343
- inserted plus the distance to the end of the vector.
344
-
345
  ``` cpp
346
  constexpr iterator erase(const_iterator position);
347
  constexpr iterator erase(const_iterator first, const_iterator last);
348
  constexpr void pop_back();
349
  ```
350
 
351
  *Effects:* Invalidates iterators and references at or after the point of
352
  the erase.
353
 
 
 
 
354
  *Complexity:* The destructor of `T` is called the number of times equal
355
  to the number of the elements erased, but the assignment operator of `T`
356
  is called the number of times equal to the number of elements in the
357
  vector after the erased elements.
358
 
359
- *Throws:* Nothing unless an exception is thrown by the assignment
360
- operator or move assignment operator of `T`.
361
-
362
  #### Erasure <a id="vector.erasure">[[vector.erasure]]</a>
363
 
364
  ``` cpp
365
  template<class T, class Allocator, class U>
366
  constexpr typename vector<T, Allocator>::size_type
 
5
  A `vector` is a sequence container that supports (amortized) constant
6
  time insert and erase operations at the end; insert and erase in the
7
  middle take linear time. Storage management is handled automatically,
8
  though hints can be given to improve efficiency.
9
 
10
+ A `vector` meets all of the requirements of a container
11
+ [[container.reqmts]], of a reversible container
12
+ [[container.rev.reqmts]], of an allocator-aware container
13
+ [[container.alloc.reqmts]], of a sequence container, including most of
14
+ the optional sequence container requirements [[sequence.reqmts]], and,
15
+ for an element type other than `bool`, of a contiguous container
16
+ [[container.reqmts]]. The exceptions are the `push_front`,
17
+ `prepend_range`, `pop_front`, and `emplace_front` member functions,
18
+ which are not provided. Descriptions are provided here only for
19
+ operations on `vector` that are not described in one of these tables or
20
+ for operations where there is additional semantic information.
21
 
22
  The types `iterator` and `const_iterator` meet the constexpr iterator
23
  requirements [[iterator.requirements.general]].
24
 
25
  ``` cpp
 
32
  using allocator_type = Allocator;
33
  using pointer = typename allocator_traits<Allocator>::pointer;
34
  using const_pointer = typename allocator_traits<Allocator>::const_pointer;
35
  using reference = value_type&;
36
  using const_reference = const value_type&;
37
+ using size_type = implementation-defined // type of vector::size_type; // see [container.requirements]
38
+ using difference_type = implementation-defined // type of vector::difference_type; // see [container.requirements]
39
  using iterator = implementation-defined // type of vector::iterator; // see [container.requirements]
40
  using const_iterator = implementation-defined // type of vector::const_iterator; // see [container.requirements]
41
  using reverse_iterator = std::reverse_iterator<iterator>;
42
  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
43
 
 
46
  constexpr explicit vector(const Allocator&) noexcept;
47
  constexpr explicit vector(size_type n, const Allocator& = Allocator());
48
  constexpr vector(size_type n, const T& value, const Allocator& = Allocator());
49
  template<class InputIterator>
50
  constexpr vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
51
+ template<container-compatible-range<T> R>
52
+ constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());
53
  constexpr vector(const vector& x);
54
  constexpr vector(vector&&) noexcept;
55
+ constexpr vector(const vector&, const type_identity_t<Allocator>&);
56
+ constexpr vector(vector&&, const type_identity_t<Allocator>&);
57
  constexpr vector(initializer_list<T>, const Allocator& = Allocator());
58
  constexpr ~vector();
59
  constexpr vector& operator=(const vector& x);
60
  constexpr vector& operator=(vector&& x)
61
  noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
62
  allocator_traits<Allocator>::is_always_equal::value);
63
  constexpr vector& operator=(initializer_list<T>);
64
  template<class InputIterator>
65
  constexpr void assign(InputIterator first, InputIterator last);
66
+ template<container-compatible-range<T> R>
67
+ constexpr void assign_range(R&& rg);
68
  constexpr void assign(size_type n, const T& u);
69
  constexpr void assign(initializer_list<T>);
70
  constexpr allocator_type get_allocator() const noexcept;
71
 
72
  // iterators
 
110
 
111
  // [vector.modifiers], modifiers
112
  template<class... Args> constexpr reference emplace_back(Args&&... args);
113
  constexpr void push_back(const T& x);
114
  constexpr void push_back(T&& x);
115
+ template<container-compatible-range<T> R>
116
+ constexpr void append_range(R&& rg);
117
  constexpr void pop_back();
118
 
119
  template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
120
  constexpr iterator insert(const_iterator position, const T& x);
121
  constexpr iterator insert(const_iterator position, T&& x);
122
  constexpr iterator insert(const_iterator position, size_type n, const T& x);
123
  template<class InputIterator>
124
  constexpr iterator insert(const_iterator position,
125
  InputIterator first, InputIterator last);
126
+ template<container-compatible-range<T> R>
127
+ constexpr iterator insert_range(const_iterator position, R&& rg);
128
  constexpr iterator insert(const_iterator position, initializer_list<T> il);
129
  constexpr iterator erase(const_iterator position);
130
  constexpr iterator erase(const_iterator first, const_iterator last);
131
  constexpr void swap(vector&)
132
  noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
 
136
 
137
  template<class InputIterator, class Allocator = allocator<iter-value-type<InputIterator>>>
138
  vector(InputIterator, InputIterator, Allocator = Allocator())
139
  -> vector<iter-value-type<InputIterator>, Allocator>;
140
 
141
+ template<ranges::input_range R, class Allocator = allocator<ranges::range_value_t<R>>>
142
+ vector(from_range_t, R&&, Allocator = Allocator())
143
+ -> vector<ranges::range_value_t<R>, Allocator>;
 
144
  }
145
  ```
146
 
147
  An incomplete type `T` may be used when instantiating `vector` if the
148
  allocator meets the allocator completeness requirements
149
  [[allocator.requirements.completeness]]. `T` shall be complete before
150
  any member of the resulting specialization of `vector` is referenced.
151
 
152
+ #### Constructors <a id="vector.cons">[[vector.cons]]</a>
153
 
154
  ``` cpp
155
  constexpr explicit vector(const Allocator&) noexcept;
156
  ```
157
 
 
192
  using the specified allocator.
193
 
194
  *Complexity:* Makes only N calls to the copy constructor of `T` (where N
195
  is the distance between `first` and `last`) and no reallocations if
196
  iterators `first` and `last` are of forward, bidirectional, or random
197
+ access categories. It makes order N calls to the copy constructor of `T`
198
+ and order log N reallocations if they are just input iterators.
199
+
200
+ ``` cpp
201
+ template<container-compatible-range<T> R>
202
+ constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());
203
+ ```
204
+
205
+ *Effects:* Constructs a `vector` object with the elements of the range
206
+ `rg`, using the specified allocator.
207
+
208
+ *Complexity:* Initializes exactly N elements from the results of
209
+ dereferencing successive iterators of `rg`, where N is
210
+ `ranges::distance(rg)`. Performs no reallocations if `R` models
211
+ `ranges::forward_range` or `ranges::sized_range`; otherwise, performs
212
+ order log N reallocations and order N calls to the copy or move
213
+ constructor of `T`.
214
 
215
  #### Capacity <a id="vector.capacity">[[vector.capacity]]</a>
216
 
217
  ``` cpp
218
  constexpr size_type capacity() const noexcept;
 
236
  `capacity()` otherwise. Reallocation happens at this point if and only
237
  if the current capacity is less than the argument of `reserve()`. If an
238
  exception is thrown other than by the move constructor of a
239
  non-*Cpp17CopyInsertable* type, there are no effects.
240
 
241
+ *Throws:* `length_error` if `n > max_size()`.[^4]
242
+
243
  *Complexity:* It does not change the size of the sequence and takes at
244
  most linear time in the size of the sequence.
245
 
 
 
246
  *Remarks:* Reallocation invalidates all the references, pointers, and
247
  iterators referring to the elements in the sequence, as well as the
248
  past-the-end iterator.
249
 
250
  [*Note 1*: If no reallocation happens, they remain
 
335
  constexpr iterator insert(const_iterator position, const T& x);
336
  constexpr iterator insert(const_iterator position, T&& x);
337
  constexpr iterator insert(const_iterator position, size_type n, const T& x);
338
  template<class InputIterator>
339
  constexpr iterator insert(const_iterator position, InputIterator first, InputIterator last);
340
+ template<container-compatible-range<T> R>
341
+ constexpr iterator insert_range(const_iterator position, R&& rg);
342
  constexpr iterator insert(const_iterator position, initializer_list<T>);
343
 
344
  template<class... Args> constexpr reference emplace_back(Args&&... args);
345
  template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
346
  constexpr void push_back(const T& x);
347
  constexpr void push_back(T&& x);
348
+ template<container-compatible-range<T> R>
349
+ constexpr void append_range(R&& rg);
350
  ```
351
 
352
+ *Complexity:* If reallocation happens, linear in the number of elements
353
+ of the resulting vector; otherwise, linear in the number of elements
354
+ inserted plus the distance to the end of the vector.
355
+
356
  *Remarks:* Causes reallocation if the new size is greater than the old
357
  capacity. Reallocation invalidates all the references, pointers, and
358
  iterators referring to the elements in the sequence, as well as the
359
  past-the-end iterator. If no reallocation happens, then references,
360
  pointers, and iterators before the insertion point remain valid but
 
366
  at the end and `T` is *Cpp17CopyInsertable* or
367
  `is_nothrow_move_constructible_v<T>` is `true`, there are no effects.
368
  Otherwise, if an exception is thrown by the move constructor of a
369
  non-*Cpp17CopyInsertable* `T`, the effects are unspecified.
370
 
 
 
 
 
371
  ``` cpp
372
  constexpr iterator erase(const_iterator position);
373
  constexpr iterator erase(const_iterator first, const_iterator last);
374
  constexpr void pop_back();
375
  ```
376
 
377
  *Effects:* Invalidates iterators and references at or after the point of
378
  the erase.
379
 
380
+ *Throws:* Nothing unless an exception is thrown by the assignment
381
+ operator or move assignment operator of `T`.
382
+
383
  *Complexity:* The destructor of `T` is called the number of times equal
384
  to the number of the elements erased, but the assignment operator of `T`
385
  is called the number of times equal to the number of elements in the
386
  vector after the erased elements.
387
 
 
 
 
388
  #### Erasure <a id="vector.erasure">[[vector.erasure]]</a>
389
 
390
  ``` cpp
391
  template<class T, class Allocator, class U>
392
  constexpr typename vector<T, Allocator>::size_type