From Jason Turner

[range.drop.view]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpux2vl6uu/{from.md → to.md} +15 -18
tmp/tmpux2vl6uu/{from.md → to.md} RENAMED
@@ -3,44 +3,40 @@
3
  ``` cpp
4
  namespace std::ranges {
5
  template<view V>
6
  class drop_view : public view_interface<drop_view<V>> {
7
  public:
8
- drop_view() = default;
9
- constexpr drop_view(V base, range_difference_t<V> count);
10
 
11
  constexpr V base() const & requires copy_constructible<V> { return base_; }
12
  constexpr V base() && { return std::move(base_); }
13
 
14
  constexpr auto begin()
15
- requires (!(simple-view<V> && random_access_range<V>));
 
16
  constexpr auto begin() const
17
- requires random_access_range<const V>;
18
 
19
- constexpr auto end()
20
- requires (!simple-view<V>)
21
  { return ranges::end(base_); }
22
 
23
- constexpr auto end() const
24
- requires range<const V>
25
  { return ranges::end(base_); }
26
 
27
- constexpr auto size()
28
- requires sized_range<V>
29
- {
30
  const auto s = ranges::size(base_);
31
  const auto c = static_cast<decltype(s)>(count_);
32
  return s < c ? 0 : s - c;
33
  }
34
 
35
- constexpr auto size() const
36
- requires sized_range<const V>
37
- {
38
  const auto s = ranges::size(base_);
39
  const auto c = static_cast<decltype(s)>(count_);
40
  return s < c ? 0 : s - c;
41
  }
 
42
  private:
43
  V base_ = V(); // exposition only
44
  range_difference_t<V> count_ = 0; // exposition only
45
  };
46
 
@@ -48,27 +44,28 @@ namespace std::ranges {
48
  drop_view(R&&, range_difference_t<R>) -> drop_view<views::all_t<R>>;
49
  }
50
  ```
51
 
52
  ``` cpp
53
- constexpr drop_view(V base, range_difference_t<V> count);
54
  ```
55
 
56
  *Preconditions:* `count >= 0` is `true`.
57
 
58
  *Effects:* Initializes *base\_* with `std::move(base)` and *count\_*
59
  with `count`.
60
 
61
  ``` cpp
62
  constexpr auto begin()
63
- requires (!(simple-view<V> && random_access_range<V>));
 
64
  constexpr auto begin() const
65
- requires random_access_range<const V>;
66
  ```
67
 
68
  *Returns:*
69
- `ranges::next(ranges::begin(base_), count_, ranges::end(base_))`.
70
 
71
  *Remarks:* In order to provide the amortized constant-time complexity
72
  required by the `range` concept when `drop_view` models `forward_range`,
73
  the first overload caches the result within the `drop_view` for use on
74
  subsequent calls.
 
3
  ``` cpp
4
  namespace std::ranges {
5
  template<view V>
6
  class drop_view : public view_interface<drop_view<V>> {
7
  public:
8
+ drop_view() requires default_initializable<V> = default;
9
+ constexpr explicit drop_view(V base, range_difference_t<V> count);
10
 
11
  constexpr V base() const & requires copy_constructible<V> { return base_; }
12
  constexpr V base() && { return std::move(base_); }
13
 
14
  constexpr auto begin()
15
+ requires (!(simple-view<V> &&
16
+ random_access_range<const V> && sized_range<const V>));
17
  constexpr auto begin() const
18
+ requires random_access_range<const V> && sized_range<const V>;
19
 
20
+ constexpr auto end() requires (!simple-view<V>)
 
21
  { return ranges::end(base_); }
22
 
23
+ constexpr auto end() const requires range<const V>
 
24
  { return ranges::end(base_); }
25
 
26
+ constexpr auto size() requires sized_range<V> {
 
 
27
  const auto s = ranges::size(base_);
28
  const auto c = static_cast<decltype(s)>(count_);
29
  return s < c ? 0 : s - c;
30
  }
31
 
32
+ constexpr auto size() const requires sized_range<const V> {
 
 
33
  const auto s = ranges::size(base_);
34
  const auto c = static_cast<decltype(s)>(count_);
35
  return s < c ? 0 : s - c;
36
  }
37
+
38
  private:
39
  V base_ = V(); // exposition only
40
  range_difference_t<V> count_ = 0; // exposition only
41
  };
42
 
 
44
  drop_view(R&&, range_difference_t<R>) -> drop_view<views::all_t<R>>;
45
  }
46
  ```
47
 
48
  ``` cpp
49
+ constexpr explicit drop_view(V base, range_difference_t<V> count);
50
  ```
51
 
52
  *Preconditions:* `count >= 0` is `true`.
53
 
54
  *Effects:* Initializes *base\_* with `std::move(base)` and *count\_*
55
  with `count`.
56
 
57
  ``` cpp
58
  constexpr auto begin()
59
+ requires (!(simple-view<V> &&
60
+ random_access_range<const V> && sized_range<const V>));
61
  constexpr auto begin() const
62
+ requires random_access_range<const V> && sized_range<const V>;
63
  ```
64
 
65
  *Returns:*
66
+ `ranges::next(ranges::begin(`*`base_`*`), `*`count_`*`, ranges::end(`*`base_`*`))`.
67
 
68
  *Remarks:* In order to provide the amortized constant-time complexity
69
  required by the `range` concept when `drop_view` models `forward_range`,
70
  the first overload caches the result within the `drop_view` for use on
71
  subsequent calls.