tmp/tmpclt_znua/{from.md → to.md}
RENAMED
|
@@ -5,23 +5,23 @@
|
|
| 5 |
The components in [[range.utility]] are general utilities for
|
| 6 |
representing and manipulating ranges.
|
| 7 |
|
| 8 |
### Helper concepts <a id="range.utility.helpers">[[range.utility.helpers]]</a>
|
| 9 |
|
| 10 |
-
Many of the types in
|
| 11 |
-
|
| 12 |
|
| 13 |
``` cpp
|
| 14 |
template<class R>
|
| 15 |
concept simple-view = // exposition only
|
| 16 |
view<R> && range<const R> &&
|
| 17 |
same_as<iterator_t<R>, iterator_t<const R>> &&
|
| 18 |
same_as<sentinel_t<R>, sentinel_t<const R>>;
|
| 19 |
|
| 20 |
template<class I>
|
| 21 |
concept has-arrow = // exposition only
|
| 22 |
-
input_iterator<I> && (is_pointer_v<I> || requires(I i) { i.operator->(); });
|
| 23 |
|
| 24 |
template<class T, class U>
|
| 25 |
concept different-from = // exposition only
|
| 26 |
!same_as<remove_cvref_t<T>, remove_cvref_t<U>>;
|
| 27 |
|
|
@@ -135,21 +135,21 @@ shall be complete, and model both `derived_from<view_interface<D>>` and
|
|
| 135 |
``` cpp
|
| 136 |
constexpr decltype(auto) front() requires forward_range<D>;
|
| 137 |
constexpr decltype(auto) front() const requires forward_range<const D>;
|
| 138 |
```
|
| 139 |
|
| 140 |
-
|
| 141 |
|
| 142 |
*Effects:* Equivalent to: `return *ranges::begin(`*`derived`*`());`
|
| 143 |
|
| 144 |
``` cpp
|
| 145 |
constexpr decltype(auto) back() requires bidirectional_range<D> && common_range<D>;
|
| 146 |
constexpr decltype(auto) back() const
|
| 147 |
requires bidirectional_range<const D> && common_range<const D>;
|
| 148 |
```
|
| 149 |
|
| 150 |
-
|
| 151 |
|
| 152 |
*Effects:* Equivalent to:
|
| 153 |
`return *ranges::prev(ranges::end(`*`derived`*`()));`
|
| 154 |
|
| 155 |
### Sub-ranges <a id="range.subrange">[[range.subrange]]</a>
|
|
@@ -216,21 +216,21 @@ namespace std::ranges {
|
|
| 216 |
template<different-from<subrange> PairLike>
|
| 217 |
requires pair-like-convertible-from<PairLike, const I&, const S&>
|
| 218 |
constexpr operator PairLike() const;
|
| 219 |
|
| 220 |
constexpr I begin() const requires copyable<I>;
|
| 221 |
-
|
| 222 |
constexpr S end() const;
|
| 223 |
|
| 224 |
constexpr bool empty() const;
|
| 225 |
constexpr make-unsigned-like-t<iter_difference_t<I>> size() const
|
| 226 |
requires (K == subrange_kind::sized);
|
| 227 |
|
| 228 |
-
|
| 229 |
requires forward_iterator<I>;
|
| 230 |
-
|
| 231 |
-
|
| 232 |
requires bidirectional_iterator<I>;
|
| 233 |
constexpr subrange& advance(iter_difference_t<I> n);
|
| 234 |
};
|
| 235 |
|
| 236 |
template<input_or_output_iterator I, sentinel_for<I> S>
|
|
@@ -309,11 +309,11 @@ constexpr I begin() const requires copyable<I>;
|
|
| 309 |
```
|
| 310 |
|
| 311 |
*Effects:* Equivalent to: `return `*`begin_`*`;`
|
| 312 |
|
| 313 |
``` cpp
|
| 314 |
-
|
| 315 |
```
|
| 316 |
|
| 317 |
*Effects:* Equivalent to: `return std::move(`*`begin_`*`);`
|
| 318 |
|
| 319 |
``` cpp
|
|
@@ -338,11 +338,11 @@ constexpr make-unsigned-like-t<iter_difference_t<I>> size() const
|
|
| 338 |
- If *StoreSize* is `true`, equivalent to: `return `*`size_`*`;`
|
| 339 |
- Otherwise, equivalent to:
|
| 340 |
`return `*`to-unsigned-like`*`(`*`end_`*` - `*`begin_`*`);`
|
| 341 |
|
| 342 |
``` cpp
|
| 343 |
-
|
| 344 |
requires forward_iterator<I>;
|
| 345 |
```
|
| 346 |
|
| 347 |
*Effects:* Equivalent to:
|
| 348 |
|
|
@@ -351,22 +351,22 @@ auto tmp = *this;
|
|
| 351 |
tmp.advance(n);
|
| 352 |
return tmp;
|
| 353 |
```
|
| 354 |
|
| 355 |
``` cpp
|
| 356 |
-
|
| 357 |
```
|
| 358 |
|
| 359 |
*Effects:* Equivalent to:
|
| 360 |
|
| 361 |
``` cpp
|
| 362 |
advance(n);
|
| 363 |
return std::move(*this);
|
| 364 |
```
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
-
|
| 368 |
requires bidirectional_iterator<I>;
|
| 369 |
```
|
| 370 |
|
| 371 |
*Effects:* Equivalent to:
|
| 372 |
|
|
@@ -530,30 +530,38 @@ constexpr bool reservable-container = // exposition only
|
|
| 530 |
{ c.capacity() } -> same_as<decltype(n)>;
|
| 531 |
{ c.max_size() } -> same_as<decltype(n)>;
|
| 532 |
};
|
| 533 |
```
|
| 534 |
|
| 535 |
-
Let *`container-
|
| 536 |
|
| 537 |
``` cpp
|
| 538 |
template<class Container, class Ref>
|
| 539 |
-
constexpr bool container-
|
| 540 |
requires(Container& c, Ref&& ref) {
|
| 541 |
-
requires (requires { c.
|
|
|
|
|
|
|
| 542 |
requires { c.insert(c.end(), std::forward<Ref>(ref)); });
|
| 543 |
};
|
| 544 |
```
|
| 545 |
|
| 546 |
-
Let *`container-
|
| 547 |
|
| 548 |
``` cpp
|
| 549 |
-
template<class
|
| 550 |
-
constexpr auto container-
|
| 551 |
-
|
| 552 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
else
|
| 554 |
-
|
|
|
|
| 555 |
}
|
| 556 |
```
|
| 557 |
|
| 558 |
#### `ranges::to` <a id="range.utility.conv.to">[[range.utility.conv.to]]</a>
|
| 559 |
|
|
@@ -589,21 +597,22 @@ the following manner:
|
|
| 589 |
``` cpp
|
| 590 |
C(ranges::begin(r), ranges::end(r), std::forward<Args>(args)...)
|
| 591 |
```
|
| 592 |
- Otherwise, if
|
| 593 |
- `constructible_from<C, Args...>` is `true`, and
|
| 594 |
-
- *`container-
|
| 595 |
|
| 596 |
``` cpp
|
| 597 |
C c(std::forward<Args>(args)...);
|
| 598 |
-
if constexpr (
|
| 599 |
-
c.reserve(static_cast<range_size_t<C>>(ranges::
|
| 600 |
-
ranges::
|
| 601 |
```
|
|
|
|
| 602 |
- Otherwise, if `input_range<range_reference_t<R>>` is `true`:
|
| 603 |
``` cpp
|
| 604 |
-
to<C>(r | views::transform([](auto&& elem) {
|
| 605 |
return to<range_value_t<C>>(std::forward<decltype(elem)>(elem));
|
| 606 |
}), std::forward<Args>(args)...);
|
| 607 |
```
|
| 608 |
- Otherwise, the program is ill-formed.
|
| 609 |
|
|
|
|
| 5 |
The components in [[range.utility]] are general utilities for
|
| 6 |
representing and manipulating ranges.
|
| 7 |
|
| 8 |
### Helper concepts <a id="range.utility.helpers">[[range.utility.helpers]]</a>
|
| 9 |
|
| 10 |
+
Many of the types in [[range.utility]] are specified in terms of the
|
| 11 |
+
following exposition-only concepts:
|
| 12 |
|
| 13 |
``` cpp
|
| 14 |
template<class R>
|
| 15 |
concept simple-view = // exposition only
|
| 16 |
view<R> && range<const R> &&
|
| 17 |
same_as<iterator_t<R>, iterator_t<const R>> &&
|
| 18 |
same_as<sentinel_t<R>, sentinel_t<const R>>;
|
| 19 |
|
| 20 |
template<class I>
|
| 21 |
concept has-arrow = // exposition only
|
| 22 |
+
input_iterator<I> && (is_pointer_v<I> || requires(const I i) { i.operator->(); });
|
| 23 |
|
| 24 |
template<class T, class U>
|
| 25 |
concept different-from = // exposition only
|
| 26 |
!same_as<remove_cvref_t<T>, remove_cvref_t<U>>;
|
| 27 |
|
|
|
|
| 135 |
``` cpp
|
| 136 |
constexpr decltype(auto) front() requires forward_range<D>;
|
| 137 |
constexpr decltype(auto) front() const requires forward_range<const D>;
|
| 138 |
```
|
| 139 |
|
| 140 |
+
`!empty()` is `true`.
|
| 141 |
|
| 142 |
*Effects:* Equivalent to: `return *ranges::begin(`*`derived`*`());`
|
| 143 |
|
| 144 |
``` cpp
|
| 145 |
constexpr decltype(auto) back() requires bidirectional_range<D> && common_range<D>;
|
| 146 |
constexpr decltype(auto) back() const
|
| 147 |
requires bidirectional_range<const D> && common_range<const D>;
|
| 148 |
```
|
| 149 |
|
| 150 |
+
`!empty()` is `true`.
|
| 151 |
|
| 152 |
*Effects:* Equivalent to:
|
| 153 |
`return *ranges::prev(ranges::end(`*`derived`*`()));`
|
| 154 |
|
| 155 |
### Sub-ranges <a id="range.subrange">[[range.subrange]]</a>
|
|
|
|
| 216 |
template<different-from<subrange> PairLike>
|
| 217 |
requires pair-like-convertible-from<PairLike, const I&, const S&>
|
| 218 |
constexpr operator PairLike() const;
|
| 219 |
|
| 220 |
constexpr I begin() const requires copyable<I>;
|
| 221 |
+
constexpr I begin() requires (!copyable<I>);
|
| 222 |
constexpr S end() const;
|
| 223 |
|
| 224 |
constexpr bool empty() const;
|
| 225 |
constexpr make-unsigned-like-t<iter_difference_t<I>> size() const
|
| 226 |
requires (K == subrange_kind::sized);
|
| 227 |
|
| 228 |
+
constexpr subrange next(iter_difference_t<I> n = 1) const &
|
| 229 |
requires forward_iterator<I>;
|
| 230 |
+
constexpr subrange next(iter_difference_t<I> n = 1) &&;
|
| 231 |
+
constexpr subrange prev(iter_difference_t<I> n = 1) const
|
| 232 |
requires bidirectional_iterator<I>;
|
| 233 |
constexpr subrange& advance(iter_difference_t<I> n);
|
| 234 |
};
|
| 235 |
|
| 236 |
template<input_or_output_iterator I, sentinel_for<I> S>
|
|
|
|
| 309 |
```
|
| 310 |
|
| 311 |
*Effects:* Equivalent to: `return `*`begin_`*`;`
|
| 312 |
|
| 313 |
``` cpp
|
| 314 |
+
constexpr I begin() requires (!copyable<I>);
|
| 315 |
```
|
| 316 |
|
| 317 |
*Effects:* Equivalent to: `return std::move(`*`begin_`*`);`
|
| 318 |
|
| 319 |
``` cpp
|
|
|
|
| 338 |
- If *StoreSize* is `true`, equivalent to: `return `*`size_`*`;`
|
| 339 |
- Otherwise, equivalent to:
|
| 340 |
`return `*`to-unsigned-like`*`(`*`end_`*` - `*`begin_`*`);`
|
| 341 |
|
| 342 |
``` cpp
|
| 343 |
+
constexpr subrange next(iter_difference_t<I> n = 1) const &
|
| 344 |
requires forward_iterator<I>;
|
| 345 |
```
|
| 346 |
|
| 347 |
*Effects:* Equivalent to:
|
| 348 |
|
|
|
|
| 351 |
tmp.advance(n);
|
| 352 |
return tmp;
|
| 353 |
```
|
| 354 |
|
| 355 |
``` cpp
|
| 356 |
+
constexpr subrange next(iter_difference_t<I> n = 1) &&;
|
| 357 |
```
|
| 358 |
|
| 359 |
*Effects:* Equivalent to:
|
| 360 |
|
| 361 |
``` cpp
|
| 362 |
advance(n);
|
| 363 |
return std::move(*this);
|
| 364 |
```
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
+
constexpr subrange prev(iter_difference_t<I> n = 1) const
|
| 368 |
requires bidirectional_iterator<I>;
|
| 369 |
```
|
| 370 |
|
| 371 |
*Effects:* Equivalent to:
|
| 372 |
|
|
|
|
| 530 |
{ c.capacity() } -> same_as<decltype(n)>;
|
| 531 |
{ c.max_size() } -> same_as<decltype(n)>;
|
| 532 |
};
|
| 533 |
```
|
| 534 |
|
| 535 |
+
Let *`container-appendable`* be defined as follows:
|
| 536 |
|
| 537 |
``` cpp
|
| 538 |
template<class Container, class Ref>
|
| 539 |
+
constexpr bool container-appendable = // exposition only
|
| 540 |
requires(Container& c, Ref&& ref) {
|
| 541 |
+
requires (requires { c.emplace_back(std::forward<Ref>(ref)); } ||
|
| 542 |
+
requires { c.push_back(std::forward<Ref>(ref)); } ||
|
| 543 |
+
requires { c.emplace(c.end(), std::forward<Ref>(ref)); } ||
|
| 544 |
requires { c.insert(c.end(), std::forward<Ref>(ref)); });
|
| 545 |
};
|
| 546 |
```
|
| 547 |
|
| 548 |
+
Let *`container-append`* be defined as follows:
|
| 549 |
|
| 550 |
``` cpp
|
| 551 |
+
template<class Container>
|
| 552 |
+
constexpr auto container-append(Container& c) { // exposition only
|
| 553 |
+
return [&c]<class Ref>(Ref&& ref) {
|
| 554 |
+
if constexpr (requires { c.emplace_back(declval<Ref>()); })
|
| 555 |
+
c.emplace_back(std::forward<Ref>(ref));
|
| 556 |
+
else if constexpr (requires { c.push_back(declval<Ref>()); })
|
| 557 |
+
c.push_back(std::forward<Ref>(ref));
|
| 558 |
+
else if constexpr (requires { c.emplace(c.end(), declval<Ref>()); })
|
| 559 |
+
c.emplace(c.end(), std::forward<Ref>(ref));
|
| 560 |
else
|
| 561 |
+
c.insert(c.end(), std::forward<Ref>(ref));
|
| 562 |
+
};
|
| 563 |
}
|
| 564 |
```
|
| 565 |
|
| 566 |
#### `ranges::to` <a id="range.utility.conv.to">[[range.utility.conv.to]]</a>
|
| 567 |
|
|
|
|
| 597 |
``` cpp
|
| 598 |
C(ranges::begin(r), ranges::end(r), std::forward<Args>(args)...)
|
| 599 |
```
|
| 600 |
- Otherwise, if
|
| 601 |
- `constructible_from<C, Args...>` is `true`, and
|
| 602 |
+
- *`container-appendable`*`<C, range_reference_t<R>>` is `true`:
|
| 603 |
|
| 604 |
``` cpp
|
| 605 |
C c(std::forward<Args>(args)...);
|
| 606 |
+
if constexpr (approximately_sized_range<R> && reservable-container<C>)
|
| 607 |
+
c.reserve(static_cast<range_size_t<C>>(ranges::reserve_hint(r)));
|
| 608 |
+
ranges::for_each(r, container-append(c));
|
| 609 |
```
|
| 610 |
+
- Otherwise, the program is ill-formed.
|
| 611 |
- Otherwise, if `input_range<range_reference_t<R>>` is `true`:
|
| 612 |
``` cpp
|
| 613 |
+
to<C>(ref_view(r) | views::transform([](auto&& elem) {
|
| 614 |
return to<range_value_t<C>>(std::forward<decltype(elem)>(elem));
|
| 615 |
}), std::forward<Args>(args)...);
|
| 616 |
```
|
| 617 |
- Otherwise, the program is ill-formed.
|
| 618 |
|