tmp/tmp9sperfe7/{from.md → to.md}
RENAMED
|
@@ -1,40 +1,40 @@
|
|
| 1 |
#### Class template `transform_view::iterator` <a id="range.transform.iterator">[[range.transform.iterator]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std::ranges {
|
| 5 |
-
template<input_range V,
|
| 6 |
requires view<V> && is_object_v<F> &&
|
| 7 |
regular_invocable<F&, range_reference_t<V>> &&
|
| 8 |
can-reference<invoke_result_t<F&, range_reference_t<V>>>
|
| 9 |
template<bool Const>
|
| 10 |
class transform_view<V, F>::iterator {
|
| 11 |
private:
|
| 12 |
-
using Parent =
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
conditional_t<Const, const V, V>;
|
| 16 |
-
iterator_t<Base> current_ = // exposition only
|
| 17 |
-
iterator_t<Base>();
|
| 18 |
Parent* parent_ = nullptr; // exposition only
|
|
|
|
| 19 |
public:
|
| 20 |
-
using iterator_concept = see
|
| 21 |
-
using iterator_category = see
|
| 22 |
using value_type =
|
| 23 |
-
remove_cvref_t<invoke_result_t<F&, range_reference_t<Base>>>;
|
| 24 |
using difference_type = range_difference_t<Base>;
|
| 25 |
|
| 26 |
-
iterator() = default;
|
| 27 |
constexpr iterator(Parent& parent, iterator_t<Base> current);
|
| 28 |
constexpr iterator(iterator<!Const> i)
|
| 29 |
requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
|
| 30 |
|
| 31 |
-
constexpr iterator_t<Base> base() const &
|
| 32 |
-
requires copyable<iterator_t<Base>>;
|
| 33 |
constexpr iterator_t<Base> base() &&;
|
|
|
|
| 34 |
constexpr decltype(auto) operator*() const
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
|
| 37 |
constexpr iterator& operator++();
|
| 38 |
constexpr void operator++(int);
|
| 39 |
constexpr iterator operator++(int) requires forward_range<Base>;
|
| 40 |
|
|
@@ -43,13 +43,15 @@ namespace std::ranges {
|
|
| 43 |
|
| 44 |
constexpr iterator& operator+=(difference_type n)
|
| 45 |
requires random_access_range<Base>;
|
| 46 |
constexpr iterator& operator-=(difference_type n)
|
| 47 |
requires random_access_range<Base>;
|
|
|
|
| 48 |
constexpr decltype(auto) operator[](difference_type n) const
|
| 49 |
-
requires random_access_range<Base>
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
friend constexpr bool operator==(const iterator& x, const iterator& y)
|
| 53 |
requires equality_comparable<iterator_t<Base>>;
|
| 54 |
|
| 55 |
friend constexpr bool operator<(const iterator& x, const iterator& y)
|
|
@@ -69,43 +71,32 @@ namespace std::ranges {
|
|
| 69 |
requires random_access_range<Base>;
|
| 70 |
|
| 71 |
friend constexpr iterator operator-(iterator i, difference_type n)
|
| 72 |
requires random_access_range<Base>;
|
| 73 |
friend constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 74 |
-
requires
|
| 75 |
-
|
| 76 |
-
friend constexpr decltype(auto) iter_move(const iterator& i)
|
| 77 |
-
noexcept(noexcept(invoke(*i.parent_->fun_, *i.current_)))
|
| 78 |
-
{
|
| 79 |
-
if constexpr (is_lvalue_reference_v<decltype(*i)>)
|
| 80 |
-
return std::move(*i);
|
| 81 |
-
else
|
| 82 |
-
return *i;
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
friend constexpr void iter_swap(const iterator& x, const iterator& y)
|
| 86 |
-
noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
|
| 87 |
-
requires indirectly_swappable<iterator_t<Base>>;
|
| 88 |
};
|
| 89 |
}
|
| 90 |
```
|
| 91 |
|
| 92 |
`iterator::iterator_concept` is defined as follows:
|
| 93 |
|
| 94 |
-
- If `
|
| 95 |
-
`random_access_iterator_tag`.
|
| 96 |
-
- Otherwise, if `
|
| 97 |
`iterator_concept` denotes `bidirectional_iterator_tag`.
|
| 98 |
-
- Otherwise, if `
|
| 99 |
denotes `forward_iterator_tag`.
|
| 100 |
- Otherwise, `iterator_concept` denotes `input_iterator_tag`.
|
| 101 |
|
|
|
|
|
|
|
| 102 |
`iterator::iterator_category` is defined as follows: Let `C` denote the
|
| 103 |
type `iterator_traits<iterator_t<Base>>::iterator_category`.
|
| 104 |
|
| 105 |
- If
|
| 106 |
-
`
|
| 107 |
is `true`, then
|
| 108 |
- if `C` models `derived_from<contiguous_iterator_tag>`,
|
| 109 |
`iterator_category` denotes `random_access_iterator_tag`;
|
| 110 |
- otherwise, `iterator_category` denotes `C`.
|
| 111 |
- Otherwise, `iterator_category` denotes `input_iterator_tag`.
|
|
@@ -124,21 +115,20 @@ constexpr iterator(iterator<!Const> i)
|
|
| 124 |
|
| 125 |
*Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`
|
| 126 |
and *parent\_* with `i.`*`parent_`*.
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
-
constexpr iterator_t<Base> base() const &
|
| 130 |
-
requires copyable<iterator_t<Base>>;
|
| 131 |
```
|
| 132 |
|
| 133 |
*Effects:* Equivalent to: `return `*`current_`*`;`
|
| 134 |
|
| 135 |
``` cpp
|
| 136 |
constexpr iterator_t<Base> base() &&;
|
| 137 |
```
|
| 138 |
|
| 139 |
-
*Effects:* Equivalent to: `return std::move(current_);`
|
| 140 |
|
| 141 |
``` cpp
|
| 142 |
constexpr iterator& operator++();
|
| 143 |
```
|
| 144 |
|
|
@@ -151,11 +141,11 @@ return *this;
|
|
| 151 |
|
| 152 |
``` cpp
|
| 153 |
constexpr void operator++(int);
|
| 154 |
```
|
| 155 |
|
| 156 |
-
*Effects:* Equivalent to `++current_`.
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
constexpr iterator operator++(int) requires forward_range<Base>;
|
| 160 |
```
|
| 161 |
|
|
@@ -263,31 +253,22 @@ friend constexpr iterator operator+(iterator i, difference_type n)
|
|
| 263 |
friend constexpr iterator operator+(difference_type n, iterator i)
|
| 264 |
requires random_access_range<Base>;
|
| 265 |
```
|
| 266 |
|
| 267 |
*Effects:* Equivalent to:
|
| 268 |
-
`return iterator{*i.`*`parent_`*`, i.`*`current_`*` + n};`
|
| 269 |
|
| 270 |
``` cpp
|
| 271 |
friend constexpr iterator operator-(iterator i, difference_type n)
|
| 272 |
requires random_access_range<Base>;
|
| 273 |
```
|
| 274 |
|
| 275 |
*Effects:* Equivalent to:
|
| 276 |
-
`return iterator{*i.`*`parent_`*`, i.`*`current_`*` - n};`
|
| 277 |
|
| 278 |
``` cpp
|
| 279 |
friend constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 280 |
-
requires
|
| 281 |
```
|
| 282 |
|
| 283 |
*Effects:* Equivalent to: `return x.`*`current_`*` - y.`*`current_`*`;`
|
| 284 |
|
| 285 |
-
``` cpp
|
| 286 |
-
friend constexpr void iter_swap(const iterator& x, const iterator& y)
|
| 287 |
-
noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
|
| 288 |
-
requires indirectly_swappable<iterator_t<Base>>;
|
| 289 |
-
```
|
| 290 |
-
|
| 291 |
-
*Effects:* Equivalent to
|
| 292 |
-
`ranges::iter_swap(x.`*`current_`*`, y.`*`current_`*`)`.
|
| 293 |
-
|
|
|
|
| 1 |
#### Class template `transform_view::iterator` <a id="range.transform.iterator">[[range.transform.iterator]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std::ranges {
|
| 5 |
+
template<input_range V, move_constructible F>
|
| 6 |
requires view<V> && is_object_v<F> &&
|
| 7 |
regular_invocable<F&, range_reference_t<V>> &&
|
| 8 |
can-reference<invoke_result_t<F&, range_reference_t<V>>>
|
| 9 |
template<bool Const>
|
| 10 |
class transform_view<V, F>::iterator {
|
| 11 |
private:
|
| 12 |
+
using Parent = maybe-const<Const, transform_view>; // exposition only
|
| 13 |
+
using Base = maybe-const<Const, V>; // exposition only
|
| 14 |
+
iterator_t<Base> current_ = iterator_t<Base>(); // exposition only
|
|
|
|
|
|
|
|
|
|
| 15 |
Parent* parent_ = nullptr; // exposition only
|
| 16 |
+
|
| 17 |
public:
|
| 18 |
+
using iterator_concept = see belownc;
|
| 19 |
+
using iterator_category = see belownc; // not always present
|
| 20 |
using value_type =
|
| 21 |
+
remove_cvref_t<invoke_result_t<maybe-const<Const, F>&, range_reference_t<Base>>>;
|
| 22 |
using difference_type = range_difference_t<Base>;
|
| 23 |
|
| 24 |
+
iterator() requires default_initializable<iterator_t<Base>> = default;
|
| 25 |
constexpr iterator(Parent& parent, iterator_t<Base> current);
|
| 26 |
constexpr iterator(iterator<!Const> i)
|
| 27 |
requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
|
| 28 |
|
| 29 |
+
constexpr const iterator_t<Base>& base() const & noexcept;
|
|
|
|
| 30 |
constexpr iterator_t<Base> base() &&;
|
| 31 |
+
|
| 32 |
constexpr decltype(auto) operator*() const
|
| 33 |
+
noexcept(noexcept(invoke(*parent_->fun_, *current_))) {
|
| 34 |
+
return invoke(*parent_->fun_, *current_);
|
| 35 |
+
}
|
| 36 |
|
| 37 |
constexpr iterator& operator++();
|
| 38 |
constexpr void operator++(int);
|
| 39 |
constexpr iterator operator++(int) requires forward_range<Base>;
|
| 40 |
|
|
|
|
| 43 |
|
| 44 |
constexpr iterator& operator+=(difference_type n)
|
| 45 |
requires random_access_range<Base>;
|
| 46 |
constexpr iterator& operator-=(difference_type n)
|
| 47 |
requires random_access_range<Base>;
|
| 48 |
+
|
| 49 |
constexpr decltype(auto) operator[](difference_type n) const
|
| 50 |
+
requires random_access_range<Base> {
|
| 51 |
+
return invoke(*parent_->fun_, current_[n]);
|
| 52 |
+
}
|
| 53 |
|
| 54 |
friend constexpr bool operator==(const iterator& x, const iterator& y)
|
| 55 |
requires equality_comparable<iterator_t<Base>>;
|
| 56 |
|
| 57 |
friend constexpr bool operator<(const iterator& x, const iterator& y)
|
|
|
|
| 71 |
requires random_access_range<Base>;
|
| 72 |
|
| 73 |
friend constexpr iterator operator-(iterator i, difference_type n)
|
| 74 |
requires random_access_range<Base>;
|
| 75 |
friend constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 76 |
+
requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
};
|
| 78 |
}
|
| 79 |
```
|
| 80 |
|
| 81 |
`iterator::iterator_concept` is defined as follows:
|
| 82 |
|
| 83 |
+
- If *`Base`* models `random_access_range`, then `iterator_concept`
|
| 84 |
+
denotes `random_access_iterator_tag`.
|
| 85 |
+
- Otherwise, if *`Base`* models `bidirectional_range`, then
|
| 86 |
`iterator_concept` denotes `bidirectional_iterator_tag`.
|
| 87 |
+
- Otherwise, if *`Base`* models `forward_range`, then `iterator_concept`
|
| 88 |
denotes `forward_iterator_tag`.
|
| 89 |
- Otherwise, `iterator_concept` denotes `input_iterator_tag`.
|
| 90 |
|
| 91 |
+
The member *typedef-name* `iterator_category` is defined if and only if
|
| 92 |
+
*`Base`* models `forward_range`. In that case,
|
| 93 |
`iterator::iterator_category` is defined as follows: Let `C` denote the
|
| 94 |
type `iterator_traits<iterator_t<Base>>::iterator_category`.
|
| 95 |
|
| 96 |
- If
|
| 97 |
+
`is_reference_v<invoke_result_t<maybe-const<Const, F>&, range_reference_t<Base>>>`
|
| 98 |
is `true`, then
|
| 99 |
- if `C` models `derived_from<contiguous_iterator_tag>`,
|
| 100 |
`iterator_category` denotes `random_access_iterator_tag`;
|
| 101 |
- otherwise, `iterator_category` denotes `C`.
|
| 102 |
- Otherwise, `iterator_category` denotes `input_iterator_tag`.
|
|
|
|
| 115 |
|
| 116 |
*Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`
|
| 117 |
and *parent\_* with `i.`*`parent_`*.
|
| 118 |
|
| 119 |
``` cpp
|
| 120 |
+
constexpr const iterator_t<Base>& base() const & noexcept;
|
|
|
|
| 121 |
```
|
| 122 |
|
| 123 |
*Effects:* Equivalent to: `return `*`current_`*`;`
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
constexpr iterator_t<Base> base() &&;
|
| 127 |
```
|
| 128 |
|
| 129 |
+
*Effects:* Equivalent to: `return std::move(`*`current_`*`);`
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
constexpr iterator& operator++();
|
| 133 |
```
|
| 134 |
|
|
|
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
constexpr void operator++(int);
|
| 144 |
```
|
| 145 |
|
| 146 |
+
*Effects:* Equivalent to `++`*`current_`*.
|
| 147 |
|
| 148 |
``` cpp
|
| 149 |
constexpr iterator operator++(int) requires forward_range<Base>;
|
| 150 |
```
|
| 151 |
|
|
|
|
| 253 |
friend constexpr iterator operator+(difference_type n, iterator i)
|
| 254 |
requires random_access_range<Base>;
|
| 255 |
```
|
| 256 |
|
| 257 |
*Effects:* Equivalent to:
|
| 258 |
+
`return `*`iterator`*`{*i.`*`parent_`*`, i.`*`current_`*` + n};`
|
| 259 |
|
| 260 |
``` cpp
|
| 261 |
friend constexpr iterator operator-(iterator i, difference_type n)
|
| 262 |
requires random_access_range<Base>;
|
| 263 |
```
|
| 264 |
|
| 265 |
*Effects:* Equivalent to:
|
| 266 |
+
`return `*`iterator`*`{*i.`*`parent_`*`, i.`*`current_`*` - n};`
|
| 267 |
|
| 268 |
``` cpp
|
| 269 |
friend constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 270 |
+
requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
|
| 271 |
```
|
| 272 |
|
| 273 |
*Effects:* Equivalent to: `return x.`*`current_`*` - y.`*`current_`*`;`
|
| 274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|