tmp/tmpxgxk3phq/{from.md → to.md}
RENAMED
|
@@ -1,92 +1,90 @@
|
|
| 1 |
## Specialized `<memory>` algorithms <a id="specialized.algorithms">[[specialized.algorithms]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
Unless otherwise specified, if an exception is thrown in the following
|
| 7 |
algorithms, objects constructed by a placement *new-expression*
|
| 8 |
[[expr.new]] are destroyed in an unspecified order before allowing the
|
| 9 |
exception to propagate.
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
[[specialized.algorithms]] result in undefined behavior. — *end note*]
|
| 14 |
-
|
| 15 |
-
Some algorithms specified in this clause make use of the exposition-only
|
| 16 |
-
function `voidify`:
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
template<class T>
|
| 20 |
constexpr void* voidify(T& obj) noexcept {
|
| 21 |
-
return
|
| 22 |
}
|
| 23 |
```
|
| 24 |
|
| 25 |
### Special memory concepts <a id="special.mem.concepts">[[special.mem.concepts]]</a>
|
| 26 |
|
| 27 |
Some algorithms in this subclause are constrained with the following
|
| 28 |
exposition-only concepts:
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
template<class I>
|
| 32 |
-
concept
|
| 33 |
input_iterator<I> &&
|
| 34 |
is_lvalue_reference_v<iter_reference_t<I>> &&
|
| 35 |
same_as<remove_cvref_t<iter_reference_t<I>>, iter_value_t<I>>;
|
| 36 |
```
|
| 37 |
|
| 38 |
-
A type `I` models
|
| 39 |
thrown from increment, copy construction, move construction, copy
|
| 40 |
assignment, move assignment, or indirection through valid iterators.
|
| 41 |
|
| 42 |
[*Note 1*: This concept allows some `input_iterator`
|
| 43 |
[[iterator.concept.input]] operations to throw
|
| 44 |
exceptions. — *end note*]
|
| 45 |
|
| 46 |
``` cpp
|
| 47 |
template<class S, class I>
|
| 48 |
-
concept
|
| 49 |
```
|
| 50 |
|
| 51 |
-
Types `S` and `I` model
|
| 52 |
thrown from copy construction, move construction, copy assignment, move
|
| 53 |
assignment, or comparisons between valid values of type `I` and `S`.
|
| 54 |
|
| 55 |
[*Note 2*: This concept allows some `sentinel_for`
|
| 56 |
[[iterator.concept.sentinel]] operations to throw
|
| 57 |
exceptions. — *end note*]
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
template<class R>
|
| 61 |
-
concept
|
| 62 |
range<R> &&
|
| 63 |
-
|
| 64 |
-
|
| 65 |
```
|
| 66 |
|
| 67 |
-
A type `R` models
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
template<class I>
|
| 73 |
-
concept
|
| 74 |
-
|
| 75 |
forward_iterator<I> &&
|
| 76 |
-
|
| 77 |
```
|
| 78 |
|
| 79 |
[*Note 3*: This concept allows some `forward_iterator`
|
| 80 |
[[iterator.concept.forward]] operations to throw
|
| 81 |
exceptions. — *end note*]
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
template<class R>
|
| 85 |
-
concept
|
| 86 |
-
|
| 87 |
-
|
| 88 |
```
|
| 89 |
|
| 90 |
### `uninitialized_default_construct` <a id="uninitialized.construct.default">[[uninitialized.construct.default]]</a>
|
| 91 |
|
| 92 |
``` cpp
|
|
@@ -102,14 +100,14 @@ for (; first != last; ++first)
|
|
| 102 |
typename iterator_traits<NoThrowForwardIterator>::value_type;
|
| 103 |
```
|
| 104 |
|
| 105 |
``` cpp
|
| 106 |
namespace ranges {
|
| 107 |
-
template<
|
| 108 |
requires default_initializable<iter_value_t<I>>
|
| 109 |
I uninitialized_default_construct(I first, S last);
|
| 110 |
-
template<
|
| 111 |
requires default_initializable<range_value_t<R>>
|
| 112 |
borrowed_iterator_t<R> uninitialized_default_construct(R&& r);
|
| 113 |
}
|
| 114 |
```
|
| 115 |
|
|
@@ -135,11 +133,11 @@ for (; n > 0; (void)++first, --n)
|
|
| 135 |
return first;
|
| 136 |
```
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
namespace ranges {
|
| 140 |
-
template<
|
| 141 |
requires default_initializable<iter_value_t<I>>
|
| 142 |
I uninitialized_default_construct_n(I first, iter_difference_t<I> n);
|
| 143 |
}
|
| 144 |
```
|
| 145 |
|
|
@@ -165,14 +163,14 @@ for (; first != last; ++first)
|
|
| 165 |
typename iterator_traits<NoThrowForwardIterator>::value_type();
|
| 166 |
```
|
| 167 |
|
| 168 |
``` cpp
|
| 169 |
namespace ranges {
|
| 170 |
-
template<
|
| 171 |
requires default_initializable<iter_value_t<I>>
|
| 172 |
I uninitialized_value_construct(I first, S last);
|
| 173 |
-
template<
|
| 174 |
requires default_initializable<range_value_t<R>>
|
| 175 |
borrowed_iterator_t<R> uninitialized_value_construct(R&& r);
|
| 176 |
}
|
| 177 |
```
|
| 178 |
|
|
@@ -198,11 +196,11 @@ for (; n > 0; (void)++first, --n)
|
|
| 198 |
return first;
|
| 199 |
```
|
| 200 |
|
| 201 |
``` cpp
|
| 202 |
namespace ranges {
|
| 203 |
-
template<
|
| 204 |
requires default_initializable<iter_value_t<I>>
|
| 205 |
I uninitialized_value_construct_n(I first, iter_difference_t<I> n);
|
| 206 |
}
|
| 207 |
```
|
| 208 |
|
|
@@ -235,15 +233,15 @@ for (; first != last; ++result, (void) ++first)
|
|
| 235 |
*Returns:* `result`.
|
| 236 |
|
| 237 |
``` cpp
|
| 238 |
namespace ranges {
|
| 239 |
template<input_iterator I, sentinel_for<I> S1,
|
| 240 |
-
|
| 241 |
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 242 |
uninitialized_copy_result<I, O>
|
| 243 |
uninitialized_copy(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 244 |
-
template<input_range IR,
|
| 245 |
requires constructible_from<range_value_t<OR>, range_reference_t<IR>>
|
| 246 |
uninitialized_copy_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 247 |
uninitialized_copy(IR&& in_range, OR&& out_range);
|
| 248 |
}
|
| 249 |
```
|
|
@@ -252,13 +250,12 @@ namespace ranges {
|
|
| 252 |
`ilast`).
|
| 253 |
|
| 254 |
*Effects:* Equivalent to:
|
| 255 |
|
| 256 |
``` cpp
|
| 257 |
-
for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst)
|
| 258 |
::new (voidify(*ofirst)) remove_reference_t<iter_reference_t<O>>(*ifirst);
|
| 259 |
-
}
|
| 260 |
return {std::move(ifirst), ofirst};
|
| 261 |
```
|
| 262 |
|
| 263 |
``` cpp
|
| 264 |
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
|
@@ -270,21 +267,20 @@ template<class InputIterator, class Size, class NoThrowForwardIterator>
|
|
| 270 |
`n`).
|
| 271 |
|
| 272 |
*Effects:* Equivalent to:
|
| 273 |
|
| 274 |
``` cpp
|
| 275 |
-
for ( ; n > 0; ++result, (void) ++first, --n)
|
| 276 |
::new (voidify(*result))
|
| 277 |
typename iterator_traits<NoThrowForwardIterator>::value_type(*first);
|
| 278 |
-
}
|
| 279 |
```
|
| 280 |
|
| 281 |
*Returns:* `result`.
|
| 282 |
|
| 283 |
``` cpp
|
| 284 |
namespace ranges {
|
| 285 |
-
template<input_iterator I,
|
| 286 |
requires constructible_from<iter_value_t<O>, iter_reference_t<I>>
|
| 287 |
uninitialized_copy_n_result<I, O>
|
| 288 |
uninitialized_copy_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 289 |
}
|
| 290 |
```
|
|
@@ -293,11 +289,11 @@ namespace ranges {
|
|
| 293 |
`ifirst`+\[0, `n`).
|
| 294 |
|
| 295 |
*Effects:* Equivalent to:
|
| 296 |
|
| 297 |
``` cpp
|
| 298 |
-
auto t = uninitialized_copy(counted_iterator(ifirst, n),
|
| 299 |
default_sentinel, ofirst, olast);
|
| 300 |
return {std::move(t.in).base(), t.out};
|
| 301 |
```
|
| 302 |
|
| 303 |
### `uninitialized_move` <a id="uninitialized.move">[[uninitialized.move]]</a>
|
|
@@ -321,15 +317,15 @@ return result;
|
|
| 321 |
```
|
| 322 |
|
| 323 |
``` cpp
|
| 324 |
namespace ranges {
|
| 325 |
template<input_iterator I, sentinel_for<I> S1,
|
| 326 |
-
|
| 327 |
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 328 |
uninitialized_move_result<I, O>
|
| 329 |
uninitialized_move(I ifirst, S1 ilast, O ofirst, S2 olast);
|
| 330 |
-
template<input_range IR,
|
| 331 |
requires constructible_from<range_value_t<OR>, range_rvalue_reference_t<IR>>
|
| 332 |
uninitialized_move_result<borrowed_iterator_t<IR>, borrowed_iterator_t<OR>>
|
| 333 |
uninitialized_move(IR&& in_range, OR&& out_range);
|
| 334 |
}
|
| 335 |
```
|
|
@@ -338,19 +334,18 @@ namespace ranges {
|
|
| 338 |
`ilast`).
|
| 339 |
|
| 340 |
*Effects:* Equivalent to:
|
| 341 |
|
| 342 |
``` cpp
|
| 343 |
-
for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst)
|
| 344 |
::new (voidify(*ofirst))
|
| 345 |
remove_reference_t<iter_reference_t<O>>(ranges::iter_move(ifirst));
|
| 346 |
-
}
|
| 347 |
return {std::move(ifirst), ofirst};
|
| 348 |
```
|
| 349 |
|
| 350 |
[*Note 1*: If an exception is thrown, some objects in the range
|
| 351 |
-
\[`
|
| 352 |
state. — *end note*]
|
| 353 |
|
| 354 |
``` cpp
|
| 355 |
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
| 356 |
pair<InputIterator, NoThrowForwardIterator>
|
|
@@ -369,11 +364,11 @@ for (; n > 0; ++result, (void) ++first, --n)
|
|
| 369 |
return {first, result};
|
| 370 |
```
|
| 371 |
|
| 372 |
``` cpp
|
| 373 |
namespace ranges {
|
| 374 |
-
template<input_iterator I,
|
| 375 |
requires constructible_from<iter_value_t<O>, iter_rvalue_reference_t<I>>
|
| 376 |
uninitialized_move_n_result<I, O>
|
| 377 |
uninitialized_move_n(I ifirst, iter_difference_t<I> n, O ofirst, S olast);
|
| 378 |
}
|
| 379 |
```
|
|
@@ -382,17 +377,17 @@ namespace ranges {
|
|
| 382 |
`ifirst`+\[0, `n`).
|
| 383 |
|
| 384 |
*Effects:* Equivalent to:
|
| 385 |
|
| 386 |
``` cpp
|
| 387 |
-
auto t = uninitialized_move(counted_iterator(ifirst, n),
|
| 388 |
default_sentinel, ofirst, olast);
|
| 389 |
return {std::move(t.in).base(), t.out};
|
| 390 |
```
|
| 391 |
|
| 392 |
[*Note 2*: If an exception is thrown, some objects in the range
|
| 393 |
-
`
|
| 394 |
state. — *end note*]
|
| 395 |
|
| 396 |
### `uninitialized_fill` <a id="uninitialized.fill">[[uninitialized.fill]]</a>
|
| 397 |
|
| 398 |
``` cpp
|
|
@@ -408,25 +403,24 @@ for (; first != last; ++first)
|
|
| 408 |
typename iterator_traits<NoThrowForwardIterator>::value_type(x);
|
| 409 |
```
|
| 410 |
|
| 411 |
``` cpp
|
| 412 |
namespace ranges {
|
| 413 |
-
template<
|
| 414 |
requires constructible_from<iter_value_t<I>, const T&>
|
| 415 |
I uninitialized_fill(I first, S last, const T& x);
|
| 416 |
-
template<
|
| 417 |
requires constructible_from<range_value_t<R>, const T&>
|
| 418 |
borrowed_iterator_t<R> uninitialized_fill(R&& r, const T& x);
|
| 419 |
}
|
| 420 |
```
|
| 421 |
|
| 422 |
*Effects:* Equivalent to:
|
| 423 |
|
| 424 |
``` cpp
|
| 425 |
-
for (; first != last; ++first)
|
| 426 |
::new (voidify(*first)) remove_reference_t<iter_reference_t<I>>(x);
|
| 427 |
-
}
|
| 428 |
return first;
|
| 429 |
```
|
| 430 |
|
| 431 |
``` cpp
|
| 432 |
template<class NoThrowForwardIterator, class Size, class T>
|
|
@@ -442,11 +436,11 @@ for (; n--; ++first)
|
|
| 442 |
return first;
|
| 443 |
```
|
| 444 |
|
| 445 |
``` cpp
|
| 446 |
namespace ranges {
|
| 447 |
-
template<
|
| 448 |
requires constructible_from<iter_value_t<I>, const T&>
|
| 449 |
I uninitialized_fill_n(I first, iter_difference_t<I> n, const T& x);
|
| 450 |
}
|
| 451 |
```
|
| 452 |
|
|
@@ -468,11 +462,11 @@ namespace ranges {
|
|
| 468 |
}
|
| 469 |
```
|
| 470 |
|
| 471 |
*Constraints:* The expression
|
| 472 |
`::new (declval<void*>()) T(declval<Args>()...)` is well-formed when
|
| 473 |
-
treated as an unevaluated operand.
|
| 474 |
|
| 475 |
*Effects:* Equivalent to:
|
| 476 |
|
| 477 |
``` cpp
|
| 478 |
return ::new (voidify(*location)) T(std::forward<Args>(args)...);
|
|
@@ -507,14 +501,14 @@ for (; first != last; ++first)
|
|
| 507 |
destroy_at(addressof(*first));
|
| 508 |
```
|
| 509 |
|
| 510 |
``` cpp
|
| 511 |
namespace ranges {
|
| 512 |
-
template<
|
| 513 |
requires destructible<iter_value_t<I>>
|
| 514 |
constexpr I destroy(I first, S last) noexcept;
|
| 515 |
-
template<
|
| 516 |
requires destructible<range_value_t<R>>
|
| 517 |
constexpr borrowed_iterator_t<R> destroy(R&& r) noexcept;
|
| 518 |
}
|
| 519 |
```
|
| 520 |
|
|
@@ -539,17 +533,17 @@ for (; n > 0; (void)++first, --n)
|
|
| 539 |
return first;
|
| 540 |
```
|
| 541 |
|
| 542 |
``` cpp
|
| 543 |
namespace ranges {
|
| 544 |
-
template<
|
| 545 |
requires destructible<iter_value_t<I>>
|
| 546 |
constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept;
|
| 547 |
}
|
| 548 |
```
|
| 549 |
|
| 550 |
*Effects:* Equivalent to:
|
| 551 |
|
| 552 |
``` cpp
|
| 553 |
-
return destroy(counted_iterator(first, n), default_sentinel).base();
|
| 554 |
```
|
| 555 |
|
|
|
|
| 1 |
## Specialized `<memory>` algorithms <a id="specialized.algorithms">[[specialized.algorithms]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="specialized.algorithms.general">[[specialized.algorithms.general]]</a>
|
| 4 |
+
|
| 5 |
+
The contents specified in [[specialized.algorithms]] are declared in the
|
| 6 |
+
header `<memory>`.
|
| 7 |
|
| 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 `voidify`:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 26 |
exposition-only concepts:
|
| 27 |
|
| 28 |
``` cpp
|
| 29 |
template<class I>
|
| 30 |
+
concept nothrow-input-iterator = // exposition only
|
| 31 |
input_iterator<I> &&
|
| 32 |
is_lvalue_reference_v<iter_reference_t<I>> &&
|
| 33 |
same_as<remove_cvref_t<iter_reference_t<I>>, iter_value_t<I>>;
|
| 34 |
```
|
| 35 |
|
| 36 |
+
A type `I` models `nothrow-input-iterator` only if no exceptions are
|
| 37 |
thrown from increment, copy construction, move construction, copy
|
| 38 |
assignment, move assignment, or indirection through valid iterators.
|
| 39 |
|
| 40 |
[*Note 1*: This concept allows some `input_iterator`
|
| 41 |
[[iterator.concept.input]] operations to throw
|
| 42 |
exceptions. — *end note*]
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
template<class S, class I>
|
| 46 |
+
concept nothrow-sentinel-for = sentinel_for<S, I>; // exposition only
|
| 47 |
```
|
| 48 |
|
| 49 |
+
Types `S` and `I` model `nothrow-sentinel-for` only if no exceptions are
|
| 50 |
thrown from copy construction, move construction, copy assignment, move
|
| 51 |
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>> &&
|
| 62 |
+
nothrow-sentinel-for<sentinel_t<R>, iterator_t<R>>;
|
| 63 |
```
|
| 64 |
|
| 65 |
+
A type `R` models `nothrow-input-range` only if no exceptions are thrown
|
| 66 |
+
from calls to `ranges::begin` and `ranges::end` on an object of type
|
| 67 |
+
`R`.
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
template<class I>
|
| 71 |
+
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 3*: This concept allows some `forward_iterator`
|
| 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
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
| 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 |
```
|
|
|
|
| 250 |
`ilast`).
|
| 251 |
|
| 252 |
*Effects:* Equivalent to:
|
| 253 |
|
| 254 |
``` cpp
|
| 255 |
+
for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst)
|
| 256 |
::new (voidify(*ofirst)) remove_reference_t<iter_reference_t<O>>(*ifirst);
|
|
|
|
| 257 |
return {std::move(ifirst), ofirst};
|
| 258 |
```
|
| 259 |
|
| 260 |
``` cpp
|
| 261 |
template<class InputIterator, class Size, class NoThrowForwardIterator>
|
|
|
|
| 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 |
```
|
|
|
|
| 289 |
`ifirst`+\[0, `n`).
|
| 290 |
|
| 291 |
*Effects:* Equivalent to:
|
| 292 |
|
| 293 |
``` cpp
|
| 294 |
+
auto t = uninitialized_copy(counted_iterator(std::move(ifirst), n),
|
| 295 |
default_sentinel, ofirst, olast);
|
| 296 |
return {std::move(t.in).base(), t.out};
|
| 297 |
```
|
| 298 |
|
| 299 |
### `uninitialized_move` <a id="uninitialized.move">[[uninitialized.move]]</a>
|
|
|
|
| 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 |
```
|
|
|
|
| 334 |
`ilast`).
|
| 335 |
|
| 336 |
*Effects:* Equivalent to:
|
| 337 |
|
| 338 |
``` cpp
|
| 339 |
+
for (; ifirst != ilast && ofirst != olast; ++ofirst, (void)++ifirst)
|
| 340 |
::new (voidify(*ofirst))
|
| 341 |
remove_reference_t<iter_reference_t<O>>(ranges::iter_move(ifirst));
|
|
|
|
| 342 |
return {std::move(ifirst), ofirst};
|
| 343 |
```
|
| 344 |
|
| 345 |
[*Note 1*: If an exception is thrown, some objects in the range
|
| 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>
|
|
|
|
| 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 |
```
|
|
|
|
| 377 |
`ifirst`+\[0, `n`).
|
| 378 |
|
| 379 |
*Effects:* Equivalent to:
|
| 380 |
|
| 381 |
``` cpp
|
| 382 |
+
auto t = uninitialized_move(counted_iterator(std::move(ifirst), n),
|
| 383 |
default_sentinel, ofirst, olast);
|
| 384 |
return {std::move(t.in).base(), t.out};
|
| 385 |
```
|
| 386 |
|
| 387 |
[*Note 2*: If an exception is thrown, some objects in the range
|
| 388 |
+
`ifirst`+\[0, `n`) are left in a valid but unspecified
|
| 389 |
state. — *end note*]
|
| 390 |
|
| 391 |
### `uninitialized_fill` <a id="uninitialized.fill">[[uninitialized.fill]]</a>
|
| 392 |
|
| 393 |
``` cpp
|
|
|
|
| 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 |
|
| 419 |
``` cpp
|
| 420 |
+
for (; first != last; ++first)
|
| 421 |
::new (voidify(*first)) remove_reference_t<iter_reference_t<I>>(x);
|
|
|
|
| 422 |
return first;
|
| 423 |
```
|
| 424 |
|
| 425 |
``` cpp
|
| 426 |
template<class NoThrowForwardIterator, class Size, class T>
|
|
|
|
| 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 |
|
|
|
|
| 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)...);
|
|
|
|
| 501 |
destroy_at(addressof(*first));
|
| 502 |
```
|
| 503 |
|
| 504 |
``` cpp
|
| 505 |
namespace ranges {
|
| 506 |
+
template<nothrow-input-iterator I, nothrow-sentinel-for<I> S>
|
| 507 |
requires destructible<iter_value_t<I>>
|
| 508 |
constexpr I destroy(I first, S last) noexcept;
|
| 509 |
+
template<nothrow-input-range R>
|
| 510 |
requires destructible<range_value_t<R>>
|
| 511 |
constexpr borrowed_iterator_t<R> destroy(R&& r) noexcept;
|
| 512 |
}
|
| 513 |
```
|
| 514 |
|
|
|
|
| 533 |
return first;
|
| 534 |
```
|
| 535 |
|
| 536 |
``` cpp
|
| 537 |
namespace ranges {
|
| 538 |
+
template<nothrow-input-iterator I>
|
| 539 |
requires destructible<iter_value_t<I>>
|
| 540 |
constexpr I destroy_n(I first, iter_difference_t<I> n) noexcept;
|
| 541 |
}
|
| 542 |
```
|
| 543 |
|
| 544 |
*Effects:* Equivalent to:
|
| 545 |
|
| 546 |
``` cpp
|
| 547 |
+
return destroy(counted_iterator(std::move(first), n), default_sentinel).base();
|
| 548 |
```
|
| 549 |
|