- tmp/tmpbfrrbtdz/{from.md → to.md} +130 -46
tmp/tmpbfrrbtdz/{from.md → to.md}
RENAMED
|
@@ -8,18 +8,31 @@ header `<memory>`.
|
|
| 8 |
Unless otherwise specified, if an exception is thrown in the following
|
| 9 |
algorithms, objects constructed by a placement *new-expression*
|
| 10 |
[[expr.new]] are destroyed in an unspecified order before allowing the
|
| 11 |
exception to propagate.
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
Some algorithms specified in [[specialized.algorithms]] make use of the
|
| 14 |
-
exposition-only function
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
template<class T>
|
| 18 |
constexpr void* voidify(T& obj) noexcept {
|
| 19 |
return addressof(obj);
|
| 20 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
```
|
| 22 |
|
| 23 |
### Special memory concepts <a id="special.mem.concepts">[[special.mem.concepts]]</a>
|
| 24 |
|
| 25 |
Some algorithms in this subclause are constrained with the following
|
|
@@ -52,10 +65,25 @@ assignment, or comparisons between valid values of type `I` and `S`.
|
|
| 52 |
|
| 53 |
[*Note 2*: This concept allows some `sentinel_for`
|
| 54 |
[[iterator.concept.sentinel]] operations to throw
|
| 55 |
exceptions. — *end note*]
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
``` cpp
|
| 58 |
template<class R>
|
| 59 |
concept nothrow-input-range = // exposition only
|
| 60 |
range<R> &&
|
| 61 |
nothrow-input-iterator<iterator_t<R>> &&
|
|
@@ -72,44 +100,97 @@ concept nothrow-forward-iterator = // exposition only
|
|
| 72 |
nothrow-input-iterator<I> &&
|
| 73 |
forward_iterator<I> &&
|
| 74 |
nothrow-sentinel-for<I, I>;
|
| 75 |
```
|
| 76 |
|
| 77 |
-
[*Note
|
| 78 |
[[iterator.concept.forward]] operations to throw
|
| 79 |
exceptions. — *end note*]
|
| 80 |
|
| 81 |
``` cpp
|
| 82 |
template<class R>
|
| 83 |
concept nothrow-forward-range = // exposition only
|
| 84 |
nothrow-input-range<R> &&
|
| 85 |
nothrow-forward-iterator<iterator_t<R>>;
|
| 86 |
```
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
### `uninitialized_default_construct` <a id="uninitialized.construct.default">[[uninitialized.construct.default]]</a>
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
template<class NoThrowForwardIterator>
|
| 92 |
-
void uninitialized_default_construct(NoThrowForwardIterator first,
|
|
|
|
| 93 |
```
|
| 94 |
|
| 95 |
*Effects:* Equivalent to:
|
| 96 |
|
| 97 |
``` cpp
|
| 98 |
for (; first != last; ++first)
|
| 99 |
-
::new (voidify(*first))
|
| 100 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type;
|
| 101 |
```
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
namespace ranges {
|
| 105 |
template<nothrow-forward-iterator I, nothrow-sentinel-for<I> S>
|
| 106 |
requires default_initializable<iter_value_t<I>>
|
| 107 |
-
I uninitialized_default_construct(I first, S last);
|
| 108 |
template<nothrow-forward-range R>
|
| 109 |
requires default_initializable<range_value_t<R>>
|
| 110 |
-
borrowed_iterator_t<R> uninitialized_default_construct(R&& r);
|
| 111 |
}
|
| 112 |
```
|
| 113 |
|
| 114 |
*Effects:* Equivalent to:
|
| 115 |
|
|
@@ -119,27 +200,27 @@ for (; first != last; ++first)
|
|
| 119 |
return first;
|
| 120 |
```
|
| 121 |
|
| 122 |
``` cpp
|
| 123 |
template<class NoThrowForwardIterator, class Size>
|
| 124 |
-
|
|
|
|
| 125 |
```
|
| 126 |
|
| 127 |
*Effects:* Equivalent to:
|
| 128 |
|
| 129 |
``` cpp
|
| 130 |
for (; n > 0; (void)++first, --n)
|
| 131 |
-
::new (voidify(*first))
|
| 132 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type;
|
| 133 |
return first;
|
| 134 |
```
|
| 135 |
|
| 136 |
``` cpp
|
| 137 |
namespace ranges {
|
| 138 |
template<nothrow-forward-iterator I>
|
| 139 |
requires default_initializable<iter_value_t<I>>
|
| 140 |
-
I uninitialized_default_construct_n(I first, iter_difference_t<I> n);
|
| 141 |
}
|
| 142 |
```
|
| 143 |
|
| 144 |
*Effects:* Equivalent to:
|
| 145 |
|
|
@@ -150,29 +231,29 @@ return uninitialized_default_construct(counted_iterator(first, n),
|
|
| 150 |
|
| 151 |
### `uninitialized_value_construct` <a id="uninitialized.construct.value">[[uninitialized.construct.value]]</a>
|
| 152 |
|
| 153 |
``` cpp
|
| 154 |
template<class NoThrowForwardIterator>
|
| 155 |
-
void uninitialized_value_construct(NoThrowForwardIterator first,
|
|
|
|
| 156 |
```
|
| 157 |
|
| 158 |
*Effects:* Equivalent to:
|
| 159 |
|
| 160 |
``` cpp
|
| 161 |
for (; first != last; ++first)
|
| 162 |
-
::new (voidify(*first))
|
| 163 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type();
|
| 164 |
```
|
| 165 |
|
| 166 |
``` cpp
|
| 167 |
namespace ranges {
|
| 168 |
template<nothrow-forward-iterator I, nothrow-sentinel-for<I> S>
|
| 169 |
requires default_initializable<iter_value_t<I>>
|
| 170 |
-
I uninitialized_value_construct(I first, S last);
|
| 171 |
template<nothrow-forward-range R>
|
| 172 |
requires default_initializable<range_value_t<R>>
|
| 173 |
-
borrowed_iterator_t<R> uninitialized_value_construct(R&& r);
|
| 174 |
}
|
| 175 |
```
|
| 176 |
|
| 177 |
*Effects:* Equivalent to:
|
| 178 |
|
|
@@ -182,27 +263,27 @@ for (; first != last; ++first)
|
|
| 182 |
return first;
|
| 183 |
```
|
| 184 |
|
| 185 |
``` cpp
|
| 186 |
template<class NoThrowForwardIterator, class Size>
|
| 187 |
-
|
|
|
|
| 188 |
```
|
| 189 |
|
| 190 |
*Effects:* Equivalent to:
|
| 191 |
|
| 192 |
``` cpp
|
| 193 |
for (; n > 0; (void)++first, --n)
|
| 194 |
-
::new (voidify(*first))
|
| 195 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type();
|
| 196 |
return first;
|
| 197 |
```
|
| 198 |
|
| 199 |
``` cpp
|
| 200 |
namespace ranges {
|
| 201 |
template<nothrow-forward-iterator I>
|
| 202 |
requires default_initializable<iter_value_t<I>>
|
| 203 |
-
I uninitialized_value_construct_n(I first, iter_difference_t<I> n);
|
| 204 |
}
|
| 205 |
```
|
| 206 |
|
| 207 |
*Effects:* Equivalent to:
|
| 208 |
|
|
@@ -213,37 +294,36 @@ return uninitialized_value_construct(counted_iterator(first, n),
|
|
| 213 |
|
| 214 |
### `uninitialized_copy` <a id="uninitialized.copy">[[uninitialized.copy]]</a>
|
| 215 |
|
| 216 |
``` cpp
|
| 217 |
template<class InputIterator, class NoThrowForwardIterator>
|
| 218 |
-
NoThrowForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
|
| 219 |
NoThrowForwardIterator result);
|
| 220 |
```
|
| 221 |
|
| 222 |
*Preconditions:* `result`+\[0, `(last - first)`) does not overlap with
|
| 223 |
\[`first`, `last`).
|
| 224 |
|
| 225 |
*Effects:* Equivalent to:
|
| 226 |
|
| 227 |
``` cpp
|
| 228 |
for (; first != last; ++result, (void)++first)
|
| 229 |
-
::new (voidify(*result))
|
| 230 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type(*first);
|
| 231 |
```
|
| 232 |
|
| 233 |
*Returns:* `result`.
|
| 234 |
|
| 235 |
``` cpp
|
| 236 |
namespace ranges {
|
| 237 |
template<input_iterator I, sentinel_for<I> S1,
|
| 238 |
nothrow-forward-iterator O, nothrow-sentinel-for<O> S2>
|
| 239 |
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 240 |
-
uninitialized_copy_result<I, O>
|
| 241 |
uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 242 |
template<input_range IR, nothrow-forward-range OR>
|
| 243 |
requires constructible_from<range_value_t<OR>, range_reference_t<IR>>
|
| 244 |
-
uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 245 |
uninitialized_copy(IR&& in_range, OR&& out_range);
|
| 246 |
}
|
| 247 |
```
|
| 248 |
|
| 249 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with \[`ifirst`,
|
|
@@ -257,32 +337,31 @@ for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst)
|
|
| 257 |
return {std::move(ifirst), ofirst};
|
| 258 |
```
|
| 259 |
|
| 260 |
``` cpp
|
| 261 |
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
| 262 |
-
NoThrowForwardIterator uninitialized_copy_n(InputIterator first, Size n,
|
| 263 |
NoThrowForwardIterator result);
|
| 264 |
```
|
| 265 |
|
| 266 |
*Preconditions:* `result`+\[0, `n`) does not overlap with `first`+\[0,
|
| 267 |
`n`).
|
| 268 |
|
| 269 |
*Effects:* Equivalent to:
|
| 270 |
|
| 271 |
``` cpp
|
| 272 |
for (; n > 0; ++result, (void)++first, --n)
|
| 273 |
-
::new (voidify(*result))
|
| 274 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type(*first);
|
| 275 |
```
|
| 276 |
|
| 277 |
*Returns:* `result`.
|
| 278 |
|
| 279 |
``` cpp
|
| 280 |
namespace ranges {
|
| 281 |
template<input_iterator I, nothrow-forward-iterator O, nothrow-sentinel-for<O> S>
|
| 282 |
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 283 |
-
uninitialized_copy_n_result<I, O>
|
| 284 |
uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 285 |
}
|
| 286 |
```
|
| 287 |
|
| 288 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with
|
|
@@ -298,11 +377,11 @@ return {std::move(t.in).base(), t.out};
|
|
| 298 |
|
| 299 |
### `uninitialized_move` <a id="uninitialized.move">[[uninitialized.move]]</a>
|
| 300 |
|
| 301 |
``` cpp
|
| 302 |
template<class InputIterator, class NoThrowForwardIterator>
|
| 303 |
-
NoThrowForwardIterator uninitialized_move(InputIterator first, InputIterator last,
|
| 304 |
NoThrowForwardIterator result);
|
| 305 |
```
|
| 306 |
|
| 307 |
*Preconditions:* `result`+\[0, `(last - first)`) does not overlap with
|
| 308 |
\[`first`, `last`).
|
|
@@ -310,24 +389,24 @@ template<class InputIterator, class NoThrowForwardIterator>
|
|
| 310 |
*Effects:* Equivalent to:
|
| 311 |
|
| 312 |
``` cpp
|
| 313 |
for (; first != last; (void)++result, ++first)
|
| 314 |
::new (voidify(*result))
|
| 315 |
-
|
| 316 |
return result;
|
| 317 |
```
|
| 318 |
|
| 319 |
``` cpp
|
| 320 |
namespace ranges {
|
| 321 |
template<input_iterator I, sentinel_for<I> S1,
|
| 322 |
nothrow-forward-iterator O, nothrow-sentinel-for<O> S2>
|
| 323 |
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 324 |
-
uninitialized_move_result<I, O>
|
| 325 |
uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 326 |
template<input_range IR, nothrow-forward-range OR>
|
| 327 |
requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>
|
| 328 |
-
uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 329 |
uninitialized_move(IR&& in_range, OR&& out_range);
|
| 330 |
}
|
| 331 |
```
|
| 332 |
|
| 333 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with \[`ifirst`,
|
|
@@ -346,11 +425,11 @@ return {std::move(ifirst), ofirst};
|
|
| 346 |
\[`ifirst`, `ilast`) are left in a valid, but unspecified
|
| 347 |
state. — *end note*]
|
| 348 |
|
| 349 |
``` cpp
|
| 350 |
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
| 351 |
-
pair<InputIterator, NoThrowForwardIterator>
|
| 352 |
uninitialized_move_n(InputIterator first, Size n, NoThrowForwardIterator result);
|
| 353 |
```
|
| 354 |
|
| 355 |
*Preconditions:* `result`+\[0, `n`) does not overlap with `first`+\[0,
|
| 356 |
`n`).
|
|
@@ -358,19 +437,19 @@ template<class InputIterator, class Size, class NoThrowForwardIterator>
|
|
| 358 |
*Effects:* Equivalent to:
|
| 359 |
|
| 360 |
``` cpp
|
| 361 |
for (; n > 0; ++result, (void)++first, --n)
|
| 362 |
::new (voidify(*result))
|
| 363 |
-
|
| 364 |
return {first, result};
|
| 365 |
```
|
| 366 |
|
| 367 |
``` cpp
|
| 368 |
namespace ranges {
|
| 369 |
template<input_iterator I, nothrow-forward-iterator O, nothrow-sentinel-for<O> S>
|
| 370 |
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 371 |
-
uninitialized_move_n_result<I, O>
|
| 372 |
uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 373 |
}
|
| 374 |
```
|
| 375 |
|
| 376 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with
|
|
@@ -390,29 +469,29 @@ state. — *end note*]
|
|
| 390 |
|
| 391 |
### `uninitialized_fill` <a id="uninitialized.fill">[[uninitialized.fill]]</a>
|
| 392 |
|
| 393 |
``` cpp
|
| 394 |
template<class NoThrowForwardIterator, class T>
|
| 395 |
-
void uninitialized_fill(NoThrowForwardIterator first,
|
|
|
|
| 396 |
```
|
| 397 |
|
| 398 |
*Effects:* Equivalent to:
|
| 399 |
|
| 400 |
``` cpp
|
| 401 |
for (; first != last; ++first)
|
| 402 |
-
::new (voidify(*first))
|
| 403 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type(x);
|
| 404 |
```
|
| 405 |
|
| 406 |
``` cpp
|
| 407 |
namespace ranges {
|
| 408 |
template<nothrow-forward-iterator I, nothrow-sentinel-for<I> S, class T>
|
| 409 |
requires constructible_from<iter_value_t<I>, const T&>
|
| 410 |
-
I uninitialized_fill(I first, S last, const T& x);
|
| 411 |
template<nothrow-forward-range R, class T>
|
| 412 |
requires constructible_from<range_value_t<R>, const T&>
|
| 413 |
-
borrowed_iterator_t<R> uninitialized_fill(R&& r, const T& x);
|
| 414 |
}
|
| 415 |
```
|
| 416 |
|
| 417 |
*Effects:* Equivalent to:
|
| 418 |
|
|
@@ -422,27 +501,27 @@ for (; first != last; ++first)
|
|
| 422 |
return first;
|
| 423 |
```
|
| 424 |
|
| 425 |
``` cpp
|
| 426 |
template<class NoThrowForwardIterator, class Size, class T>
|
| 427 |
-
|
|
|
|
| 428 |
```
|
| 429 |
|
| 430 |
*Effects:* Equivalent to:
|
| 431 |
|
| 432 |
``` cpp
|
| 433 |
for (; n--; ++first)
|
| 434 |
-
::new (voidify(*first))
|
| 435 |
-
typename iterator_traits<NoThrowForwardIterator>::value_type(x);
|
| 436 |
return first;
|
| 437 |
```
|
| 438 |
|
| 439 |
``` cpp
|
| 440 |
namespace ranges {
|
| 441 |
template<nothrow-forward-iterator I, class T>
|
| 442 |
requires constructible_from<iter_value_t<I>, const T&>
|
| 443 |
-
I uninitialized_fill_n(I first, iter_difference_t<I> n, const T& x);
|
| 444 |
}
|
| 445 |
```
|
| 446 |
|
| 447 |
*Effects:* Equivalent to:
|
| 448 |
|
|
@@ -460,17 +539,22 @@ namespace ranges {
|
|
| 460 |
template<class T, class... Args>
|
| 461 |
constexpr T* construct_at(T* location, Args&&... args);
|
| 462 |
}
|
| 463 |
```
|
| 464 |
|
| 465 |
-
*Constraints:* The expression
|
| 466 |
`::new (declval<void*>()) T(declval<Args>()...)` is well-formed when
|
| 467 |
treated as an unevaluated operand [[term.unevaluated.operand]].
|
| 468 |
|
|
|
|
|
|
|
| 469 |
*Effects:* Equivalent to:
|
| 470 |
|
| 471 |
``` cpp
|
|
|
|
|
|
|
|
|
|
| 472 |
return ::new (voidify(*location)) T(std::forward<Args>(args)...);
|
| 473 |
```
|
| 474 |
|
| 475 |
### `destroy` <a id="specialized.destroy">[[specialized.destroy]]</a>
|
| 476 |
|
|
|
|
| 8 |
Unless otherwise specified, if an exception is thrown in the following
|
| 9 |
algorithms, objects constructed by a placement *new-expression*
|
| 10 |
[[expr.new]] are destroyed in an unspecified order before allowing the
|
| 11 |
exception to propagate.
|
| 12 |
|
| 13 |
+
[*Note 1*: When new objects are created by the algorithms specified in
|
| 14 |
+
[[specialized.algorithms]], the lifetime ends for any existing objects
|
| 15 |
+
(including potentially-overlapping subobjects [[intro.object]]) in
|
| 16 |
+
storage that is reused [[basic.life]]. — *end note*]
|
| 17 |
+
|
| 18 |
Some algorithms specified in [[specialized.algorithms]] make use of the
|
| 19 |
+
following exposition-only function templates:
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
template<class T>
|
| 23 |
constexpr void* voidify(T& obj) noexcept {
|
| 24 |
return addressof(obj);
|
| 25 |
}
|
| 26 |
+
|
| 27 |
+
template<class I>
|
| 28 |
+
decltype(auto) deref-move(I& it) {
|
| 29 |
+
if constexpr (is_lvalue_reference_v<decltype(*it)>)
|
| 30 |
+
return std::move(*it);
|
| 31 |
+
else
|
| 32 |
+
return *it;
|
| 33 |
+
}
|
| 34 |
```
|
| 35 |
|
| 36 |
### Special memory concepts <a id="special.mem.concepts">[[special.mem.concepts]]</a>
|
| 37 |
|
| 38 |
Some algorithms in this subclause are constrained with the following
|
|
|
|
| 65 |
|
| 66 |
[*Note 2*: This concept allows some `sentinel_for`
|
| 67 |
[[iterator.concept.sentinel]] operations to throw
|
| 68 |
exceptions. — *end note*]
|
| 69 |
|
| 70 |
+
``` cpp
|
| 71 |
+
template<class S, class I>
|
| 72 |
+
concept nothrow-sized-sentinel-for = // exposition only
|
| 73 |
+
nothrow-sentinel-for<S, I> &&
|
| 74 |
+
sized_sentinel_for<S, I>;
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
Types `S` and `I` model `nothrow-sized-sentinel-for` only if no
|
| 78 |
+
exceptions are thrown from the `-` operator for valid values of type `I`
|
| 79 |
+
and `S`.
|
| 80 |
+
|
| 81 |
+
[*Note 3*: This concept allows some `sized_sentinel_for`
|
| 82 |
+
[[iterator.concept.sizedsentinel]] operations to throw
|
| 83 |
+
exceptions. — *end note*]
|
| 84 |
+
|
| 85 |
``` cpp
|
| 86 |
template<class R>
|
| 87 |
concept nothrow-input-range = // exposition only
|
| 88 |
range<R> &&
|
| 89 |
nothrow-input-iterator<iterator_t<R>> &&
|
|
|
|
| 100 |
nothrow-input-iterator<I> &&
|
| 101 |
forward_iterator<I> &&
|
| 102 |
nothrow-sentinel-for<I, I>;
|
| 103 |
```
|
| 104 |
|
| 105 |
+
[*Note 4*: This concept allows some `forward_iterator`
|
| 106 |
[[iterator.concept.forward]] operations to throw
|
| 107 |
exceptions. — *end note*]
|
| 108 |
|
| 109 |
``` cpp
|
| 110 |
template<class R>
|
| 111 |
concept nothrow-forward-range = // exposition only
|
| 112 |
nothrow-input-range<R> &&
|
| 113 |
nothrow-forward-iterator<iterator_t<R>>;
|
| 114 |
```
|
| 115 |
|
| 116 |
+
``` cpp
|
| 117 |
+
template<class I>
|
| 118 |
+
concept nothrow-bidirectional-iterator = // exposition only
|
| 119 |
+
nothrow-forward-iterator<I> &&
|
| 120 |
+
bidirectional_iterator<I>;
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
A type `I` models `nothrow-bidirectional-iterator` only if no exceptions
|
| 124 |
+
are thrown from decrementing valid iterators.
|
| 125 |
+
|
| 126 |
+
[*Note 5*: This concept allows some `bidirectional_iterator`
|
| 127 |
+
[[iterator.concept.bidir]] operations to throw
|
| 128 |
+
exceptions. — *end note*]
|
| 129 |
+
|
| 130 |
+
``` cpp
|
| 131 |
+
template<class R>
|
| 132 |
+
concept nothrow-bidirectional-range = // exposition only
|
| 133 |
+
nothrow-forward-range<R> &&
|
| 134 |
+
nothrow-bidirectional-iterator<iterator_t<R>>;
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
``` cpp
|
| 138 |
+
template<class I>
|
| 139 |
+
concept nothrow-random-access-iterator = // exposition only
|
| 140 |
+
nothrow-bidirectional-iterator<I> &&
|
| 141 |
+
random_access_iterator<I> &&
|
| 142 |
+
nothrow-sized-sentinel-for<I, I>;
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
A type `I` models `nothrow-random-access-iterator` only if no exceptions
|
| 146 |
+
are thrown from comparisons of valid iterators, or the `-`, `+`, `-=`,
|
| 147 |
+
`+=`, `[]` operators on valid values of type `I` and
|
| 148 |
+
`iter_difference_t<I>`.
|
| 149 |
+
|
| 150 |
+
[*Note 6*: This concept allows some `random_access_iterator`
|
| 151 |
+
[[iterator.concept.random.access]] operations to throw
|
| 152 |
+
exceptions. — *end note*]
|
| 153 |
+
|
| 154 |
+
``` cpp
|
| 155 |
+
template<class R>
|
| 156 |
+
concept nothrow-random-access-range = // exposition only
|
| 157 |
+
nothrow-bidirectional-range<R> &&
|
| 158 |
+
nothrow-random-access-iterator<iterator_t<R>>;
|
| 159 |
+
|
| 160 |
+
template<class R>
|
| 161 |
+
concept nothrow-sized-random-access-range = // exposition only
|
| 162 |
+
nothrow-random-access-range<R> && sized_range<R>;
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
A type `R` models `nothrow-sized-random-access-range` only if no
|
| 166 |
+
exceptions are thrown from the call to `ranges::size` on an object of
|
| 167 |
+
type `R`.
|
| 168 |
+
|
| 169 |
### `uninitialized_default_construct` <a id="uninitialized.construct.default">[[uninitialized.construct.default]]</a>
|
| 170 |
|
| 171 |
``` cpp
|
| 172 |
template<class NoThrowForwardIterator>
|
| 173 |
+
constexpr void uninitialized_default_construct(NoThrowForwardIterator first,
|
| 174 |
+
NoThrowForwardIterator last);
|
| 175 |
```
|
| 176 |
|
| 177 |
*Effects:* Equivalent to:
|
| 178 |
|
| 179 |
``` cpp
|
| 180 |
for (; first != last; ++first)
|
| 181 |
+
::new (voidify(*first)) iterator_traits<NoThrowForwardIterator>::value_type;
|
|
|
|
| 182 |
```
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
namespace ranges {
|
| 186 |
template<nothrow-forward-iterator I, nothrow-sentinel-for<I> S>
|
| 187 |
requires default_initializable<iter_value_t<I>>
|
| 188 |
+
constexpr I uninitialized_default_construct(I first, S last);
|
| 189 |
template<nothrow-forward-range R>
|
| 190 |
requires default_initializable<range_value_t<R>>
|
| 191 |
+
constexpr borrowed_iterator_t<R> uninitialized_default_construct(R&& r);
|
| 192 |
}
|
| 193 |
```
|
| 194 |
|
| 195 |
*Effects:* Equivalent to:
|
| 196 |
|
|
|
|
| 200 |
return first;
|
| 201 |
```
|
| 202 |
|
| 203 |
``` cpp
|
| 204 |
template<class NoThrowForwardIterator, class Size>
|
| 205 |
+
constexpr NoThrowForwardIterator
|
| 206 |
+
uninitialized_default_construct_n(NoThrowForwardIterator first, Size n);
|
| 207 |
```
|
| 208 |
|
| 209 |
*Effects:* Equivalent to:
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
for (; n > 0; (void)++first, --n)
|
| 213 |
+
::new (voidify(*first)) iterator_traits<NoThrowForwardIterator>::value_type;
|
|
|
|
| 214 |
return first;
|
| 215 |
```
|
| 216 |
|
| 217 |
``` cpp
|
| 218 |
namespace ranges {
|
| 219 |
template<nothrow-forward-iterator I>
|
| 220 |
requires default_initializable<iter_value_t<I>>
|
| 221 |
+
constexpr I uninitialized_default_construct_n(I first, iter_difference_t<I> n);
|
| 222 |
}
|
| 223 |
```
|
| 224 |
|
| 225 |
*Effects:* Equivalent to:
|
| 226 |
|
|
|
|
| 231 |
|
| 232 |
### `uninitialized_value_construct` <a id="uninitialized.construct.value">[[uninitialized.construct.value]]</a>
|
| 233 |
|
| 234 |
``` cpp
|
| 235 |
template<class NoThrowForwardIterator>
|
| 236 |
+
constexpr void uninitialized_value_construct(NoThrowForwardIterator first,
|
| 237 |
+
NoThrowForwardIterator last);
|
| 238 |
```
|
| 239 |
|
| 240 |
*Effects:* Equivalent to:
|
| 241 |
|
| 242 |
``` cpp
|
| 243 |
for (; first != last; ++first)
|
| 244 |
+
::new (voidify(*first)) iterator_traits<NoThrowForwardIterator>::value_type();
|
|
|
|
| 245 |
```
|
| 246 |
|
| 247 |
``` cpp
|
| 248 |
namespace ranges {
|
| 249 |
template<nothrow-forward-iterator I, nothrow-sentinel-for<I> S>
|
| 250 |
requires default_initializable<iter_value_t<I>>
|
| 251 |
+
constexpr I uninitialized_value_construct(I first, S last);
|
| 252 |
template<nothrow-forward-range R>
|
| 253 |
requires default_initializable<range_value_t<R>>
|
| 254 |
+
constexpr borrowed_iterator_t<R> uninitialized_value_construct(R&& r);
|
| 255 |
}
|
| 256 |
```
|
| 257 |
|
| 258 |
*Effects:* Equivalent to:
|
| 259 |
|
|
|
|
| 263 |
return first;
|
| 264 |
```
|
| 265 |
|
| 266 |
``` cpp
|
| 267 |
template<class NoThrowForwardIterator, class Size>
|
| 268 |
+
constexpr NoThrowForwardIterator
|
| 269 |
+
uninitialized_value_construct_n(NoThrowForwardIterator first, Size n);
|
| 270 |
```
|
| 271 |
|
| 272 |
*Effects:* Equivalent to:
|
| 273 |
|
| 274 |
``` cpp
|
| 275 |
for (; n > 0; (void)++first, --n)
|
| 276 |
+
::new (voidify(*first)) iterator_traits<NoThrowForwardIterator>::value_type();
|
|
|
|
| 277 |
return first;
|
| 278 |
```
|
| 279 |
|
| 280 |
``` cpp
|
| 281 |
namespace ranges {
|
| 282 |
template<nothrow-forward-iterator I>
|
| 283 |
requires default_initializable<iter_value_t<I>>
|
| 284 |
+
constexpr I uninitialized_value_construct_n(I first, iter_difference_t<I> n);
|
| 285 |
}
|
| 286 |
```
|
| 287 |
|
| 288 |
*Effects:* Equivalent to:
|
| 289 |
|
|
|
|
| 294 |
|
| 295 |
### `uninitialized_copy` <a id="uninitialized.copy">[[uninitialized.copy]]</a>
|
| 296 |
|
| 297 |
``` cpp
|
| 298 |
template<class InputIterator, class NoThrowForwardIterator>
|
| 299 |
+
constexpr NoThrowForwardIterator uninitialized_copy(InputIterator first, InputIterator last,
|
| 300 |
NoThrowForwardIterator result);
|
| 301 |
```
|
| 302 |
|
| 303 |
*Preconditions:* `result`+\[0, `(last - first)`) does not overlap with
|
| 304 |
\[`first`, `last`).
|
| 305 |
|
| 306 |
*Effects:* Equivalent to:
|
| 307 |
|
| 308 |
``` cpp
|
| 309 |
for (; first != last; ++result, (void)++first)
|
| 310 |
+
::new (voidify(*result)) iterator_traits<NoThrowForwardIterator>::value_type(*first);
|
|
|
|
| 311 |
```
|
| 312 |
|
| 313 |
*Returns:* `result`.
|
| 314 |
|
| 315 |
``` cpp
|
| 316 |
namespace ranges {
|
| 317 |
template<input_iterator I, sentinel_for<I> S1,
|
| 318 |
nothrow-forward-iterator O, nothrow-sentinel-for<O> S2>
|
| 319 |
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 320 |
+
constexpr uninitialized_copy_result<I, O>
|
| 321 |
uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 322 |
template<input_range IR, nothrow-forward-range OR>
|
| 323 |
requires constructible_from<range_value_t<OR>, range_reference_t<IR>>
|
| 324 |
+
constexpr uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 325 |
uninitialized_copy(IR&& in_range, OR&& out_range);
|
| 326 |
}
|
| 327 |
```
|
| 328 |
|
| 329 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with \[`ifirst`,
|
|
|
|
| 337 |
return {std::move(ifirst), ofirst};
|
| 338 |
```
|
| 339 |
|
| 340 |
``` cpp
|
| 341 |
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
| 342 |
+
constexpr NoThrowForwardIterator uninitialized_copy_n(InputIterator first, Size n,
|
| 343 |
NoThrowForwardIterator result);
|
| 344 |
```
|
| 345 |
|
| 346 |
*Preconditions:* `result`+\[0, `n`) does not overlap with `first`+\[0,
|
| 347 |
`n`).
|
| 348 |
|
| 349 |
*Effects:* Equivalent to:
|
| 350 |
|
| 351 |
``` cpp
|
| 352 |
for (; n > 0; ++result, (void)++first, --n)
|
| 353 |
+
::new (voidify(*result)) iterator_traits<NoThrowForwardIterator>::value_type(*first);
|
|
|
|
| 354 |
```
|
| 355 |
|
| 356 |
*Returns:* `result`.
|
| 357 |
|
| 358 |
``` cpp
|
| 359 |
namespace ranges {
|
| 360 |
template<input_iterator I, nothrow-forward-iterator O, nothrow-sentinel-for<O> S>
|
| 361 |
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 362 |
+
constexpr uninitialized_copy_n_result<I, O>
|
| 363 |
uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 364 |
}
|
| 365 |
```
|
| 366 |
|
| 367 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with
|
|
|
|
| 377 |
|
| 378 |
### `uninitialized_move` <a id="uninitialized.move">[[uninitialized.move]]</a>
|
| 379 |
|
| 380 |
``` cpp
|
| 381 |
template<class InputIterator, class NoThrowForwardIterator>
|
| 382 |
+
constexpr NoThrowForwardIterator uninitialized_move(InputIterator first, InputIterator last,
|
| 383 |
NoThrowForwardIterator result);
|
| 384 |
```
|
| 385 |
|
| 386 |
*Preconditions:* `result`+\[0, `(last - first)`) does not overlap with
|
| 387 |
\[`first`, `last`).
|
|
|
|
| 389 |
*Effects:* Equivalent to:
|
| 390 |
|
| 391 |
``` cpp
|
| 392 |
for (; first != last; (void)++result, ++first)
|
| 393 |
::new (voidify(*result))
|
| 394 |
+
iterator_traits<NoThrowForwardIterator>::value_type(deref-move(first));
|
| 395 |
return result;
|
| 396 |
```
|
| 397 |
|
| 398 |
``` cpp
|
| 399 |
namespace ranges {
|
| 400 |
template<input_iterator I, sentinel_for<I> S1,
|
| 401 |
nothrow-forward-iterator O, nothrow-sentinel-for<O> S2>
|
| 402 |
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 403 |
+
constexpr uninitialized_move_result<I, O>
|
| 404 |
uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 405 |
template<input_range IR, nothrow-forward-range OR>
|
| 406 |
requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>
|
| 407 |
+
constexpr uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 408 |
uninitialized_move(IR&& in_range, OR&& out_range);
|
| 409 |
}
|
| 410 |
```
|
| 411 |
|
| 412 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with \[`ifirst`,
|
|
|
|
| 425 |
\[`ifirst`, `ilast`) are left in a valid, but unspecified
|
| 426 |
state. — *end note*]
|
| 427 |
|
| 428 |
``` cpp
|
| 429 |
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
| 430 |
+
constexpr pair<InputIterator, NoThrowForwardIterator>
|
| 431 |
uninitialized_move_n(InputIterator first, Size n, NoThrowForwardIterator result);
|
| 432 |
```
|
| 433 |
|
| 434 |
*Preconditions:* `result`+\[0, `n`) does not overlap with `first`+\[0,
|
| 435 |
`n`).
|
|
|
|
| 437 |
*Effects:* Equivalent to:
|
| 438 |
|
| 439 |
``` cpp
|
| 440 |
for (; n > 0; ++result, (void)++first, --n)
|
| 441 |
::new (voidify(*result))
|
| 442 |
+
iterator_traits<NoThrowForwardIterator>::value_type(deref-move(first));
|
| 443 |
return {first, result};
|
| 444 |
```
|
| 445 |
|
| 446 |
``` cpp
|
| 447 |
namespace ranges {
|
| 448 |
template<input_iterator I, nothrow-forward-iterator O, nothrow-sentinel-for<O> S>
|
| 449 |
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 450 |
+
constexpr uninitialized_move_n_result<I, O>
|
| 451 |
uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 452 |
}
|
| 453 |
```
|
| 454 |
|
| 455 |
*Preconditions:* \[`ofirst`, `olast`) does not overlap with
|
|
|
|
| 469 |
|
| 470 |
### `uninitialized_fill` <a id="uninitialized.fill">[[uninitialized.fill]]</a>
|
| 471 |
|
| 472 |
``` cpp
|
| 473 |
template<class NoThrowForwardIterator, class T>
|
| 474 |
+
constexpr void uninitialized_fill(NoThrowForwardIterator first,
|
| 475 |
+
NoThrowForwardIterator last, const T& x);
|
| 476 |
```
|
| 477 |
|
| 478 |
*Effects:* Equivalent to:
|
| 479 |
|
| 480 |
``` cpp
|
| 481 |
for (; first != last; ++first)
|
| 482 |
+
::new (voidify(*first)) iterator_traits<NoThrowForwardIterator>::value_type(x);
|
|
|
|
| 483 |
```
|
| 484 |
|
| 485 |
``` cpp
|
| 486 |
namespace ranges {
|
| 487 |
template<nothrow-forward-iterator I, nothrow-sentinel-for<I> S, class T>
|
| 488 |
requires constructible_from<iter_value_t<I>, const T&>
|
| 489 |
+
constexpr I uninitialized_fill(I first, S last, const T& x);
|
| 490 |
template<nothrow-forward-range R, class T>
|
| 491 |
requires constructible_from<range_value_t<R>, const T&>
|
| 492 |
+
constexpr borrowed_iterator_t<R> uninitialized_fill(R&& r, const T& x);
|
| 493 |
}
|
| 494 |
```
|
| 495 |
|
| 496 |
*Effects:* Equivalent to:
|
| 497 |
|
|
|
|
| 501 |
return first;
|
| 502 |
```
|
| 503 |
|
| 504 |
``` cpp
|
| 505 |
template<class NoThrowForwardIterator, class Size, class T>
|
| 506 |
+
constexpr NoThrowForwardIterator
|
| 507 |
+
uninitialized_fill_n(NoThrowForwardIterator first, Size n, const T& x);
|
| 508 |
```
|
| 509 |
|
| 510 |
*Effects:* Equivalent to:
|
| 511 |
|
| 512 |
``` cpp
|
| 513 |
for (; n--; ++first)
|
| 514 |
+
::new (voidify(*first)) iterator_traits<NoThrowForwardIterator>::value_type(x);
|
|
|
|
| 515 |
return first;
|
| 516 |
```
|
| 517 |
|
| 518 |
``` cpp
|
| 519 |
namespace ranges {
|
| 520 |
template<nothrow-forward-iterator I, class T>
|
| 521 |
requires constructible_from<iter_value_t<I>, const T&>
|
| 522 |
+
constexpr I uninitialized_fill_n(I first, iter_difference_t<I> n, const T& x);
|
| 523 |
}
|
| 524 |
```
|
| 525 |
|
| 526 |
*Effects:* Equivalent to:
|
| 527 |
|
|
|
|
| 539 |
template<class T, class... Args>
|
| 540 |
constexpr T* construct_at(T* location, Args&&... args);
|
| 541 |
}
|
| 542 |
```
|
| 543 |
|
| 544 |
+
*Constraints:* `is_unbounded_array_v<T>` is `false`. The expression
|
| 545 |
`::new (declval<void*>()) T(declval<Args>()...)` is well-formed when
|
| 546 |
treated as an unevaluated operand [[term.unevaluated.operand]].
|
| 547 |
|
| 548 |
+
*Mandates:* If `is_array_v<T>` is `true`, `sizeof...(Args)` is zero.
|
| 549 |
+
|
| 550 |
*Effects:* Equivalent to:
|
| 551 |
|
| 552 |
``` cpp
|
| 553 |
+
if constexpr (is_array_v<T>)
|
| 554 |
+
return ::new (voidify(*location)) T[1]();
|
| 555 |
+
else
|
| 556 |
return ::new (voidify(*location)) T(std::forward<Args>(args)...);
|
| 557 |
```
|
| 558 |
|
| 559 |
### `destroy` <a id="specialized.destroy">[[specialized.destroy]]</a>
|
| 560 |
|