tmp/tmpoph7br8i/{from.md → to.md}
RENAMED
|
@@ -2,35 +2,39 @@
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std::ranges {
|
| 5 |
template<input_range V, size_t N>
|
| 6 |
requires view<V> && has-tuple-element<range_value_t<V>, N> &&
|
| 7 |
-
has-tuple-element<remove_reference_t<range_reference_t<V>>, N>
|
|
|
|
| 8 |
template<bool Const>
|
| 9 |
-
class elements_view<V, N>::iterator {
|
| 10 |
-
using Base =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
iterator_t<Base> current_ = iterator_t<Base>();
|
| 13 |
public:
|
| 14 |
-
using
|
|
|
|
| 15 |
using value_type = remove_cvref_t<tuple_element_t<N, range_value_t<Base>>>;
|
| 16 |
using difference_type = range_difference_t<Base>;
|
| 17 |
|
| 18 |
-
iterator() = default;
|
| 19 |
constexpr explicit iterator(iterator_t<Base> current);
|
| 20 |
constexpr iterator(iterator<!Const> i)
|
| 21 |
requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
|
| 22 |
|
| 23 |
-
constexpr iterator_t<Base> base() const&
|
| 24 |
-
requires copyable<iterator_t<Base>>;
|
| 25 |
constexpr iterator_t<Base> base() &&;
|
| 26 |
|
| 27 |
constexpr decltype(auto) operator*() const
|
| 28 |
-
{ return get
|
| 29 |
|
| 30 |
constexpr iterator& operator++();
|
| 31 |
-
constexpr void operator++(int)
|
| 32 |
constexpr iterator operator++(int) requires forward_range<Base>;
|
| 33 |
|
| 34 |
constexpr iterator& operator--() requires bidirectional_range<Base>;
|
| 35 |
constexpr iterator operator--(int) requires bidirectional_range<Base>;
|
| 36 |
|
|
@@ -39,20 +43,20 @@ namespace std::ranges {
|
|
| 39 |
constexpr iterator& operator-=(difference_type x)
|
| 40 |
requires random_access_range<Base>;
|
| 41 |
|
| 42 |
constexpr decltype(auto) operator[](difference_type n) const
|
| 43 |
requires random_access_range<Base>
|
| 44 |
-
{ return get
|
| 45 |
|
| 46 |
friend constexpr bool operator==(const iterator& x, const iterator& y)
|
| 47 |
requires equality_comparable<iterator_t<Base>>;
|
| 48 |
|
| 49 |
friend constexpr bool operator<(const iterator& x, const iterator& y)
|
| 50 |
requires random_access_range<Base>;
|
| 51 |
friend constexpr bool operator>(const iterator& x, const iterator& y)
|
| 52 |
requires random_access_range<Base>;
|
| 53 |
-
friend constexpr bool operator<=(const iterator&
|
| 54 |
requires random_access_range<Base>;
|
| 55 |
friend constexpr bool operator>=(const iterator& x, const iterator& y)
|
| 56 |
requires random_access_range<Base>;
|
| 57 |
friend constexpr auto operator<=>(const iterator& x, const iterator& y)
|
| 58 |
requires random_access_range<Base> && three_way_comparable<iterator_t<Base>>;
|
|
@@ -62,15 +66,51 @@ namespace std::ranges {
|
|
| 62 |
friend constexpr iterator operator+(difference_type x, const iterator& y)
|
| 63 |
requires random_access_range<Base>;
|
| 64 |
friend constexpr iterator operator-(const iterator& x, difference_type y)
|
| 65 |
requires random_access_range<Base>;
|
| 66 |
friend constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 67 |
-
requires
|
| 68 |
};
|
| 69 |
}
|
| 70 |
```
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
``` cpp
|
| 73 |
constexpr explicit iterator(iterator_t<Base> current);
|
| 74 |
```
|
| 75 |
|
| 76 |
*Effects:* Initializes *current\_* with `std::move(current)`.
|
|
@@ -81,12 +121,11 @@ constexpr iterator(iterator<!Const> i)
|
|
| 81 |
```
|
| 82 |
|
| 83 |
*Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`.
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
-
constexpr iterator_t<Base> base() const&
|
| 87 |
-
requires copyable<iterator_t<Base>>;
|
| 88 |
```
|
| 89 |
|
| 90 |
*Effects:* Equivalent to: `return `*`current_`*`;`
|
| 91 |
|
| 92 |
``` cpp
|
|
@@ -105,11 +144,11 @@ constexpr iterator& operator++();
|
|
| 105 |
++current_;
|
| 106 |
return *this;
|
| 107 |
```
|
| 108 |
|
| 109 |
``` cpp
|
| 110 |
-
constexpr void operator++(int)
|
| 111 |
```
|
| 112 |
|
| 113 |
*Effects:* Equivalent to: `++`*`current_`*.
|
| 114 |
|
| 115 |
``` cpp
|
|
@@ -146,11 +185,11 @@ auto temp = *this;
|
|
| 146 |
--current_;
|
| 147 |
return temp;
|
| 148 |
```
|
| 149 |
|
| 150 |
``` cpp
|
| 151 |
-
constexpr iterator& operator+=(difference_type n)
|
| 152 |
requires random_access_range<Base>;
|
| 153 |
```
|
| 154 |
|
| 155 |
*Effects:* Equivalent to:
|
| 156 |
|
|
@@ -217,28 +256,28 @@ friend constexpr auto operator<=>(const iterator& x, const iterator& y)
|
|
| 217 |
``` cpp
|
| 218 |
friend constexpr iterator operator+(const iterator& x, difference_type y)
|
| 219 |
requires random_access_range<Base>;
|
| 220 |
```
|
| 221 |
|
| 222 |
-
*Effects:* Equivalent to: `return iterator{x} += y;`
|
| 223 |
|
| 224 |
``` cpp
|
| 225 |
friend constexpr iterator operator+(difference_type x, const iterator& y)
|
| 226 |
requires random_access_range<Base>;
|
| 227 |
```
|
| 228 |
|
| 229 |
*Effects:* Equivalent to: `return y + x;`
|
| 230 |
|
| 231 |
``` cpp
|
| 232 |
-
constexpr iterator operator-(const iterator& x, difference_type y)
|
| 233 |
requires random_access_range<Base>;
|
| 234 |
```
|
| 235 |
|
| 236 |
-
*Effects:* Equivalent to: `return iterator{x} -= y;`
|
| 237 |
|
| 238 |
``` cpp
|
| 239 |
-
constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 240 |
-
requires
|
| 241 |
```
|
| 242 |
|
| 243 |
*Effects:* Equivalent to: `return x.`*`current_`*` - y.`*`current_`*`;`
|
| 244 |
|
|
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std::ranges {
|
| 5 |
template<input_range V, size_t N>
|
| 6 |
requires view<V> && has-tuple-element<range_value_t<V>, N> &&
|
| 7 |
+
has-tuple-element<remove_reference_t<range_reference_t<V>>, N> &&
|
| 8 |
+
returnable-element<range_reference_t<V>, N>
|
| 9 |
template<bool Const>
|
| 10 |
+
class elements_view<V, N>::iterator {
|
| 11 |
+
using Base = maybe-const<Const, V>; // exposition only
|
| 12 |
+
|
| 13 |
+
iterator_t<Base> current_ = iterator_t<Base>(); // exposition only
|
| 14 |
+
|
| 15 |
+
static constexpr decltype(auto) get-element(const iterator_t<Base>& i); // exposition only
|
| 16 |
|
|
|
|
| 17 |
public:
|
| 18 |
+
using iterator_concept = see below;
|
| 19 |
+
using iterator_category = see below; // not always present
|
| 20 |
using value_type = remove_cvref_t<tuple_element_t<N, range_value_t<Base>>>;
|
| 21 |
using difference_type = range_difference_t<Base>;
|
| 22 |
|
| 23 |
+
iterator() requires default_initializable<iterator_t<Base>> = default;
|
| 24 |
constexpr explicit iterator(iterator_t<Base> current);
|
| 25 |
constexpr iterator(iterator<!Const> i)
|
| 26 |
requires Const && convertible_to<iterator_t<V>, iterator_t<Base>>;
|
| 27 |
|
| 28 |
+
constexpr const iterator_t<Base>& base() const & noexcept;
|
|
|
|
| 29 |
constexpr iterator_t<Base> base() &&;
|
| 30 |
|
| 31 |
constexpr decltype(auto) operator*() const
|
| 32 |
+
{ return get-element(current_); }
|
| 33 |
|
| 34 |
constexpr iterator& operator++();
|
| 35 |
+
constexpr void operator++(int);
|
| 36 |
constexpr iterator operator++(int) requires forward_range<Base>;
|
| 37 |
|
| 38 |
constexpr iterator& operator--() requires bidirectional_range<Base>;
|
| 39 |
constexpr iterator operator--(int) requires bidirectional_range<Base>;
|
| 40 |
|
|
|
|
| 43 |
constexpr iterator& operator-=(difference_type x)
|
| 44 |
requires random_access_range<Base>;
|
| 45 |
|
| 46 |
constexpr decltype(auto) operator[](difference_type n) const
|
| 47 |
requires random_access_range<Base>
|
| 48 |
+
{ return get-element(current_ + n); }
|
| 49 |
|
| 50 |
friend constexpr bool operator==(const iterator& x, const iterator& y)
|
| 51 |
requires equality_comparable<iterator_t<Base>>;
|
| 52 |
|
| 53 |
friend constexpr bool operator<(const iterator& x, const iterator& y)
|
| 54 |
requires random_access_range<Base>;
|
| 55 |
friend constexpr bool operator>(const iterator& x, const iterator& y)
|
| 56 |
requires random_access_range<Base>;
|
| 57 |
+
friend constexpr bool operator<=(const iterator& x, const iterator& y)
|
| 58 |
requires random_access_range<Base>;
|
| 59 |
friend constexpr bool operator>=(const iterator& x, const iterator& y)
|
| 60 |
requires random_access_range<Base>;
|
| 61 |
friend constexpr auto operator<=>(const iterator& x, const iterator& y)
|
| 62 |
requires random_access_range<Base> && three_way_comparable<iterator_t<Base>>;
|
|
|
|
| 66 |
friend constexpr iterator operator+(difference_type x, const iterator& y)
|
| 67 |
requires random_access_range<Base>;
|
| 68 |
friend constexpr iterator operator-(const iterator& x, difference_type y)
|
| 69 |
requires random_access_range<Base>;
|
| 70 |
friend constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 71 |
+
requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
|
| 72 |
};
|
| 73 |
}
|
| 74 |
```
|
| 75 |
|
| 76 |
+
The member *typedef-name* `iterator_concept` is defined as follows:
|
| 77 |
+
|
| 78 |
+
- If *`Base`* models `random_access_range`, then `iterator_concept`
|
| 79 |
+
denotes `random_access_iterator_tag`.
|
| 80 |
+
- Otherwise, if *`Base`* models `bidirectional_range`, then
|
| 81 |
+
`iterator_concept` denotes `bidirectional_iterator_tag`.
|
| 82 |
+
- Otherwise, if *`Base`* models `forward_range`, then `iterator_concept`
|
| 83 |
+
denotes `forward_iterator_tag`.
|
| 84 |
+
- Otherwise, `iterator_concept` denotes `input_iterator_tag`.
|
| 85 |
+
|
| 86 |
+
The member *typedef-name* `iterator_category` is defined if and only if
|
| 87 |
+
*`Base`* models `forward_range`. In that case, `iterator_category` is
|
| 88 |
+
defined as follows: Let `C` denote the type
|
| 89 |
+
`iterator_traits<iterator_t<Base>>::iterator_category`.
|
| 90 |
+
|
| 91 |
+
- If `std::get<N>(*current_)` is an rvalue, `iterator_category` denotes
|
| 92 |
+
`input_iterator_tag`.
|
| 93 |
+
- Otherwise, if `C` models `derived_from<random_access_iterator_tag>`,
|
| 94 |
+
`iterator_category` denotes `random_access_iterator_tag`.
|
| 95 |
+
- Otherwise, `iterator_category` denotes `C`.
|
| 96 |
+
|
| 97 |
+
``` cpp
|
| 98 |
+
static constexpr decltype(auto) get-element(const iterator_t<Base>& i);
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
*Effects:* Equivalent to:
|
| 102 |
+
|
| 103 |
+
``` cpp
|
| 104 |
+
if constexpr (is_reference_v<range_reference_t<Base>>) {
|
| 105 |
+
return std::get<N>(*i);
|
| 106 |
+
} else {
|
| 107 |
+
using E = remove_cv_t<tuple_element_t<N, range_reference_t<Base>>>;
|
| 108 |
+
return static_cast<E>(std::get<N>(*i));
|
| 109 |
+
}
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
``` cpp
|
| 113 |
constexpr explicit iterator(iterator_t<Base> current);
|
| 114 |
```
|
| 115 |
|
| 116 |
*Effects:* Initializes *current\_* with `std::move(current)`.
|
|
|
|
| 121 |
```
|
| 122 |
|
| 123 |
*Effects:* Initializes *current\_* with `std::move(i.`*`current_`*`)`.
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
+
constexpr const iterator_t<Base>& base() const & noexcept;
|
|
|
|
| 127 |
```
|
| 128 |
|
| 129 |
*Effects:* Equivalent to: `return `*`current_`*`;`
|
| 130 |
|
| 131 |
``` cpp
|
|
|
|
| 144 |
++current_;
|
| 145 |
return *this;
|
| 146 |
```
|
| 147 |
|
| 148 |
``` cpp
|
| 149 |
+
constexpr void operator++(int);
|
| 150 |
```
|
| 151 |
|
| 152 |
*Effects:* Equivalent to: `++`*`current_`*.
|
| 153 |
|
| 154 |
``` cpp
|
|
|
|
| 185 |
--current_;
|
| 186 |
return temp;
|
| 187 |
```
|
| 188 |
|
| 189 |
``` cpp
|
| 190 |
+
constexpr iterator& operator+=(difference_type n)
|
| 191 |
requires random_access_range<Base>;
|
| 192 |
```
|
| 193 |
|
| 194 |
*Effects:* Equivalent to:
|
| 195 |
|
|
|
|
| 256 |
``` cpp
|
| 257 |
friend constexpr iterator operator+(const iterator& x, difference_type y)
|
| 258 |
requires random_access_range<Base>;
|
| 259 |
```
|
| 260 |
|
| 261 |
+
*Effects:* Equivalent to: `return `*`iterator`*`{x} += y;`
|
| 262 |
|
| 263 |
``` cpp
|
| 264 |
friend constexpr iterator operator+(difference_type x, const iterator& y)
|
| 265 |
requires random_access_range<Base>;
|
| 266 |
```
|
| 267 |
|
| 268 |
*Effects:* Equivalent to: `return y + x;`
|
| 269 |
|
| 270 |
``` cpp
|
| 271 |
+
friend constexpr iterator operator-(const iterator& x, difference_type y)
|
| 272 |
requires random_access_range<Base>;
|
| 273 |
```
|
| 274 |
|
| 275 |
+
*Effects:* Equivalent to: `return `*`iterator`*`{x} -= y;`
|
| 276 |
|
| 277 |
``` cpp
|
| 278 |
+
friend constexpr difference_type operator-(const iterator& x, const iterator& y)
|
| 279 |
+
requires sized_sentinel_for<iterator_t<Base>, iterator_t<Base>>;
|
| 280 |
```
|
| 281 |
|
| 282 |
*Effects:* Equivalent to: `return x.`*`current_`*` - y.`*`current_`*`;`
|
| 283 |
|