tmp/tmpj_r3did1/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Class template `enumerate_view` <a id="range.enumerate.view">[[range.enumerate.view]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std::ranges {
|
| 5 |
+
template<view V>
|
| 6 |
+
requires range-with-movable-references<V>
|
| 7 |
+
class enumerate_view : public view_interface<enumerate_view<V>> {
|
| 8 |
+
V base_ = V(); // exposition only
|
| 9 |
+
|
| 10 |
+
// [range.enumerate.iterator], class template enumerate_view::iterator
|
| 11 |
+
template<bool Const>
|
| 12 |
+
class iterator; // exposition only
|
| 13 |
+
|
| 14 |
+
// [range.enumerate.sentinel], class template enumerate_view::sentinel
|
| 15 |
+
template<bool Const>
|
| 16 |
+
class sentinel; // exposition only
|
| 17 |
+
|
| 18 |
+
public:
|
| 19 |
+
constexpr enumerate_view() requires default_initializable<V> = default;
|
| 20 |
+
constexpr explicit enumerate_view(V base);
|
| 21 |
+
|
| 22 |
+
constexpr auto begin() requires (!simple-view<V>)
|
| 23 |
+
{ return iterator<false>(ranges::begin(base_), 0); }
|
| 24 |
+
constexpr auto begin() const requires range-with-movable-references<const V>
|
| 25 |
+
{ return iterator<true>(ranges::begin(base_), 0); }
|
| 26 |
+
|
| 27 |
+
constexpr auto end() requires (!simple-view<V>) {
|
| 28 |
+
if constexpr (common_range<V> && sized_range<V>)
|
| 29 |
+
return iterator<false>(ranges::end(base_), ranges::distance(base_));
|
| 30 |
+
else
|
| 31 |
+
return sentinel<false>(ranges::end(base_));
|
| 32 |
+
}
|
| 33 |
+
constexpr auto end() const requires range-with-movable-references<const V> {
|
| 34 |
+
if constexpr (common_range<const V> && sized_range<const V>)
|
| 35 |
+
return iterator<true>(ranges::end(base_), ranges::distance(base_));
|
| 36 |
+
else
|
| 37 |
+
return sentinel<true>(ranges::end(base_));
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
constexpr auto size() requires sized_range<V>
|
| 41 |
+
{ return ranges::size(base_); }
|
| 42 |
+
constexpr auto size() const requires sized_range<const V>
|
| 43 |
+
{ return ranges::size(base_); }
|
| 44 |
+
|
| 45 |
+
constexpr V base() const & requires copy_constructible<V> { return base_; }
|
| 46 |
+
constexpr V base() && { return std::move(base_); }
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
template<class R>
|
| 50 |
+
enumerate_view(R&&) -> enumerate_view<views::all_t<R>>;
|
| 51 |
+
}
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
``` cpp
|
| 55 |
+
constexpr explicit enumerate_view(V base);
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
*Effects:* Initializes *base\_* with `std::move(base)`.
|
| 59 |
+
|