tmp/tmprj53ow6l/{from.md → to.md}
RENAMED
|
@@ -1,33 +1,34 @@
|
|
| 1 |
### All view <a id="range.all">[[range.all]]</a>
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
argument.
|
| 5 |
|
| 6 |
The name `views::all` denotes a range adaptor object
|
| 7 |
[[range.adaptor.object]]. Given a subexpression `E`, the expression
|
| 8 |
`views::all(E)` is expression-equivalent to:
|
| 9 |
|
| 10 |
- `decay-copy(E)` if the decayed type of `E` models `view`.
|
| 11 |
- Otherwise, `ref_view{E}` if that expression is well-formed.
|
| 12 |
-
- Otherwise, `
|
| 13 |
|
| 14 |
#### Class template `ref_view` <a id="range.ref.view">[[range.ref.view]]</a>
|
| 15 |
|
| 16 |
-
`ref_view` is a
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
namespace std::ranges {
|
| 20 |
template<range R>
|
| 21 |
requires is_object_v<R>
|
| 22 |
class ref_view : public view_interface<ref_view<R>> {
|
| 23 |
private:
|
| 24 |
-
R* r_
|
| 25 |
-
public:
|
| 26 |
-
constexpr ref_view() noexcept = default;
|
| 27 |
|
| 28 |
-
|
|
|
|
| 29 |
requires see below
|
| 30 |
constexpr ref_view(T&& t);
|
| 31 |
|
| 32 |
constexpr R& base() const { return *r_; }
|
| 33 |
|
|
@@ -42,32 +43,89 @@ namespace std::ranges {
|
|
| 42 |
{ return ranges::size(*r_); }
|
| 43 |
|
| 44 |
constexpr auto data() const requires contiguous_range<R>
|
| 45 |
{ return ranges::data(*r_); }
|
| 46 |
};
|
|
|
|
| 47 |
template<class R>
|
| 48 |
ref_view(R&) -> ref_view<R>;
|
| 49 |
}
|
| 50 |
```
|
| 51 |
|
| 52 |
``` cpp
|
| 53 |
-
template<
|
| 54 |
requires see below
|
| 55 |
constexpr ref_view(T&& t);
|
| 56 |
```
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
*Remarks:* Let *`FUN`* denote the exposition-only functions
|
| 59 |
|
| 60 |
``` cpp
|
| 61 |
void FUN(R&);
|
| 62 |
void FUN(R&&) = delete;
|
| 63 |
```
|
| 64 |
|
| 65 |
-
The expression in the *requires-clause* is equivalent to
|
| 66 |
|
| 67 |
``` cpp
|
| 68 |
convertible_to<T, R&> && requires { FUN(declval<T>()); }
|
| 69 |
```
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
|
|
|
| 1 |
### All view <a id="range.all">[[range.all]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="range.all.general">[[range.all.general]]</a>
|
| 4 |
+
|
| 5 |
+
`views::all` returns a view that includes all elements of its range
|
| 6 |
argument.
|
| 7 |
|
| 8 |
The name `views::all` denotes a range adaptor object
|
| 9 |
[[range.adaptor.object]]. Given a subexpression `E`, the expression
|
| 10 |
`views::all(E)` is expression-equivalent to:
|
| 11 |
|
| 12 |
- `decay-copy(E)` if the decayed type of `E` models `view`.
|
| 13 |
- Otherwise, `ref_view{E}` if that expression is well-formed.
|
| 14 |
+
- Otherwise, `owning_view{E}`.
|
| 15 |
|
| 16 |
#### Class template `ref_view` <a id="range.ref.view">[[range.ref.view]]</a>
|
| 17 |
|
| 18 |
+
`ref_view` is a view of the elements of some other range.
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
namespace std::ranges {
|
| 22 |
template<range R>
|
| 23 |
requires is_object_v<R>
|
| 24 |
class ref_view : public view_interface<ref_view<R>> {
|
| 25 |
private:
|
| 26 |
+
R* r_; // exposition only
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
public:
|
| 29 |
+
template<different-from<ref_view> T>
|
| 30 |
requires see below
|
| 31 |
constexpr ref_view(T&& t);
|
| 32 |
|
| 33 |
constexpr R& base() const { return *r_; }
|
| 34 |
|
|
|
|
| 43 |
{ return ranges::size(*r_); }
|
| 44 |
|
| 45 |
constexpr auto data() const requires contiguous_range<R>
|
| 46 |
{ return ranges::data(*r_); }
|
| 47 |
};
|
| 48 |
+
|
| 49 |
template<class R>
|
| 50 |
ref_view(R&) -> ref_view<R>;
|
| 51 |
}
|
| 52 |
```
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
+
template<different-from<ref_view> T>
|
| 56 |
requires see below
|
| 57 |
constexpr ref_view(T&& t);
|
| 58 |
```
|
| 59 |
|
| 60 |
+
*Effects:* Initializes *r\_* with
|
| 61 |
+
`addressof(static_cast<R&>(std::forward<T>(t)))`.
|
| 62 |
+
|
| 63 |
*Remarks:* Let *`FUN`* denote the exposition-only functions
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
void FUN(R&);
|
| 67 |
void FUN(R&&) = delete;
|
| 68 |
```
|
| 69 |
|
| 70 |
+
The expression in the *requires-clause* is equivalent to:
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
convertible_to<T, R&> && requires { FUN(declval<T>()); }
|
| 74 |
```
|
| 75 |
|
| 76 |
+
#### Class template `owning_view` <a id="range.owning.view">[[range.owning.view]]</a>
|
| 77 |
+
|
| 78 |
+
`owning_view` is a move-only view of the elements of some other range.
|
| 79 |
+
|
| 80 |
+
``` cpp
|
| 81 |
+
namespace std::ranges {
|
| 82 |
+
template<range R>
|
| 83 |
+
requires movable<R> && (!is-initializer-list<R>) // see [range.refinements]
|
| 84 |
+
class owning_view : public view_interface<owning_view<R>> {
|
| 85 |
+
private:
|
| 86 |
+
R r_ = R(); // exposition only
|
| 87 |
+
|
| 88 |
+
public:
|
| 89 |
+
owning_view() requires default_initializable<R> = default;
|
| 90 |
+
constexpr owning_view(R&& t);
|
| 91 |
+
|
| 92 |
+
owning_view(owning_view&&) = default;
|
| 93 |
+
owning_view& operator=(owning_view&&) = default;
|
| 94 |
+
|
| 95 |
+
constexpr R& base() & noexcept { return r_; }
|
| 96 |
+
constexpr const R& base() const & noexcept { return r_; }
|
| 97 |
+
constexpr R&& base() && noexcept { return std::move(r_); }
|
| 98 |
+
constexpr const R&& base() const && noexcept { return std::move(r_); }
|
| 99 |
+
|
| 100 |
+
constexpr iterator_t<R> begin() { return ranges::begin(r_); }
|
| 101 |
+
constexpr sentinel_t<R> end() { return ranges::end(r_); }
|
| 102 |
+
|
| 103 |
+
constexpr auto begin() const requires range<const R>
|
| 104 |
+
{ return ranges::begin(r_); }
|
| 105 |
+
constexpr auto end() const requires range<const R>
|
| 106 |
+
{ return ranges::end(r_); }
|
| 107 |
+
|
| 108 |
+
constexpr bool empty() requires requires { ranges::empty(r_); }
|
| 109 |
+
{ return ranges::empty(r_); }
|
| 110 |
+
constexpr bool empty() const requires requires { ranges::empty(r_); }
|
| 111 |
+
{ return ranges::empty(r_); }
|
| 112 |
+
|
| 113 |
+
constexpr auto size() requires sized_range<R>
|
| 114 |
+
{ return ranges::size(r_); }
|
| 115 |
+
constexpr auto size() const requires sized_range<const R>
|
| 116 |
+
{ return ranges::size(r_); }
|
| 117 |
+
|
| 118 |
+
constexpr auto data() requires contiguous_range<R>
|
| 119 |
+
{ return ranges::data(r_); }
|
| 120 |
+
constexpr auto data() const requires contiguous_range<const R>
|
| 121 |
+
{ return ranges::data(r_); }
|
| 122 |
+
};
|
| 123 |
+
}
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
``` cpp
|
| 127 |
+
constexpr owning_view(R&& t);
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
*Effects:* Initializes *r\_* with `std::move(t)`.
|
| 131 |
|