From Jason Turner

[range.take.while.sentinel]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpoz3kajbr/{from.md → to.md} +15 -4
tmp/tmpoz3kajbr/{from.md → to.md} RENAMED
@@ -4,24 +4,30 @@
4
  namespace std::ranges {
5
  template<view V, class Pred>
6
  requires input_range<V> && is_object_v<Pred> &&
7
  indirect_unary_predicate<const Pred, iterator_t<V>>
8
  template<bool Const>
9
- class take_while_view<V, Pred>::sentinel { // exposition only
10
- using Base = conditional_t<Const, const V, V>; // exposition only
11
 
12
  sentinel_t<Base> end_ = sentinel_t<Base>(); // exposition only
13
  const Pred* pred_ = nullptr; // exposition only
 
14
  public:
15
  sentinel() = default;
16
  constexpr explicit sentinel(sentinel_t<Base> end, const Pred* pred);
17
  constexpr sentinel(sentinel<!Const> s)
18
  requires Const && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
19
 
20
  constexpr sentinel_t<Base> base() const { return end_; }
21
 
22
  friend constexpr bool operator==(const iterator_t<Base>& x, const sentinel& y);
 
 
 
 
 
23
  };
24
  }
25
  ```
26
 
27
  ``` cpp
@@ -33,15 +39,20 @@ constexpr explicit sentinel(sentinel_t<Base> end, const Pred* pred);
33
  ``` cpp
34
  constexpr sentinel(sentinel<!Const> s)
35
  requires Const && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
36
  ```
37
 
38
- *Effects:* Initializes *end\_* with `s.`*`end_`* and *pred\_* with
39
- `s.`*`pred_`*.
40
 
41
  ``` cpp
42
  friend constexpr bool operator==(const iterator_t<Base>& x, const sentinel& y);
 
 
 
 
 
43
  ```
44
 
45
  *Effects:* Equivalent to:
46
  `return y.`*`end_`*` == x || !invoke(*y.`*`pred_`*`, *x);`
47
 
 
4
  namespace std::ranges {
5
  template<view V, class Pred>
6
  requires input_range<V> && is_object_v<Pred> &&
7
  indirect_unary_predicate<const Pred, iterator_t<V>>
8
  template<bool Const>
9
+ class take_while_view<V, Pred>::sentinel {
10
+ using Base = maybe-const<Const, V>; // exposition only
11
 
12
  sentinel_t<Base> end_ = sentinel_t<Base>(); // exposition only
13
  const Pred* pred_ = nullptr; // exposition only
14
+
15
  public:
16
  sentinel() = default;
17
  constexpr explicit sentinel(sentinel_t<Base> end, const Pred* pred);
18
  constexpr sentinel(sentinel<!Const> s)
19
  requires Const && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
20
 
21
  constexpr sentinel_t<Base> base() const { return end_; }
22
 
23
  friend constexpr bool operator==(const iterator_t<Base>& x, const sentinel& y);
24
+
25
+ template<bool OtherConst = !Const>
26
+ requires sentinel_for<sentinel_t<Base>, iterator_t<maybe-const<OtherConst, V>>>
27
+ friend constexpr bool operator==(const iterator_t<maybe-const<OtherConst, V>>& x,
28
+ const sentinel& y);
29
  };
30
  }
31
  ```
32
 
33
  ``` cpp
 
39
  ``` cpp
40
  constexpr sentinel(sentinel<!Const> s)
41
  requires Const && convertible_to<sentinel_t<V>, sentinel_t<Base>>;
42
  ```
43
 
44
+ *Effects:* Initializes *end\_* with `std::move(s.`*`end_`*`)` and
45
+ *pred\_* with `s.`*`pred_`*.
46
 
47
  ``` cpp
48
  friend constexpr bool operator==(const iterator_t<Base>& x, const sentinel& y);
49
+
50
+ template<bool OtherConst = !Const>
51
+ requires sentinel_for<sentinel_t<Base>, iterator_t<maybe-const<OtherConst, V>>>
52
+ friend constexpr bool operator==(const iterator_t<maybe-const<OtherConst, V>>& x,
53
+ const sentinel& y);
54
  ```
55
 
56
  *Effects:* Equivalent to:
57
  `return y.`*`end_`*` == x || !invoke(*y.`*`pred_`*`, *x);`
58