From Jason Turner

[range.split.view]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxvtp3kq9/{from.md → to.md} +88 -0
tmp/tmpxvtp3kq9/{from.md → to.md} RENAMED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Class template `split_view` <a id="range.split.view">[[range.split.view]]</a>
2
+
3
+ ``` cpp
4
+ namespace std::ranges {
5
+ template<auto> struct require-constant; // exposition only
6
+
7
+ template<class R>
8
+ concept tiny-range = // exposition only
9
+ sized_range<R> &&
10
+ requires { typename require-constant<remove_reference_t<R>::size()>; } &&
11
+ (remove_reference_t<R>::size() <= 1);
12
+
13
+ template<input_range V, forward_range Pattern>
14
+ requires view<V> && view<Pattern> &&
15
+ indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> &&
16
+ (forward_range<V> || tiny-range<Pattern>)
17
+ class split_view : public view_interface<split_view<V, Pattern>> {
18
+ private:
19
+ V base_ = V(); // exposition only
20
+ Pattern pattern_ = Pattern(); // exposition only
21
+ iterator_t<V> current_ = iterator_t<V>(); // exposition only, present only if !forward_range<V>
22
+ // [range.split.outer], class template split_view::outer-iterator
23
+ template<bool> struct outer-iterator; // exposition only
24
+ // [range.split.inner], class template split_view::inner-iterator
25
+ template<bool> struct inner-iterator; // exposition only
26
+ public:
27
+ split_view() = default;
28
+ constexpr split_view(V base, Pattern pattern);
29
+
30
+ template<input_range R>
31
+ requires constructible_from<V, views::all_t<R>> &&
32
+ constructible_from<Pattern, single_view<range_value_t<R>>>
33
+ constexpr split_view(R&& r, range_value_t<R> e);
34
+
35
+ constexpr V base() const& requires copy_constructible<V> { return base_; }
36
+ constexpr V base() && { return std::move(base_); }
37
+
38
+ constexpr auto begin() {
39
+ if constexpr (forward_range<V>)
40
+ return outer-iterator<simple-view<V>>{*this, ranges::begin(base_)};
41
+ else {
42
+ current_ = ranges::begin(base_);
43
+ return outer-iterator<false>{*this};
44
+ }
45
+ }
46
+
47
+ constexpr auto begin() const requires forward_range<V> && forward_range<const V> {
48
+ return outer-iterator<true>{*this, ranges::begin(base_)};
49
+ }
50
+
51
+ constexpr auto end() requires forward_range<V> && common_range<V> {
52
+ return outer-iterator<simple-view<V>>{*this, ranges::end(base_)};
53
+ }
54
+
55
+ constexpr auto end() const {
56
+ if constexpr (forward_range<V> && forward_range<const V> && common_range<const V>)
57
+ return outer-iterator<true>{*this, ranges::end(base_)};
58
+ else
59
+ return default_sentinel;
60
+ }
61
+ };
62
+
63
+ template<class R, class P>
64
+ split_view(R&&, P&&) -> split_view<views::all_t<R>, views::all_t<P>>;
65
+
66
+ template<input_range R>
67
+ split_view(R&&, range_value_t<R>)
68
+ -> split_view<views::all_t<R>, single_view<range_value_t<R>>>;
69
+ }
70
+ ```
71
+
72
+ ``` cpp
73
+ constexpr split_view(V base, Pattern pattern);
74
+ ```
75
+
76
+ *Effects:* Initializes *base\_* with `std::move(base)`, and *pattern\_*
77
+ with `std::move(pattern)`.
78
+
79
+ ``` cpp
80
+ template<input_range R>
81
+ requires constructible_from<V, views::all_t<R>> &&
82
+ constructible_from<Pattern, single_view<range_value_t<R>>>
83
+ constexpr split_view(R&& r, range_value_t<R> e);
84
+ ```
85
+
86
+ *Effects:* Initializes *base\_* with `views::all(std::forward<R>(r))`,
87
+ and *pattern\_* with `single_view{std::move(e)}`.
88
+