From Jason Turner

[range.drop.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpr1xdnx8m/{from.md → to.md} +32 -14
tmp/tmpr1xdnx8m/{from.md → to.md} RENAMED
@@ -1,39 +1,57 @@
1
  #### Overview <a id="range.drop.overview">[[range.drop.overview]]</a>
2
 
3
- `drop_view` produces a `view` excluding the first N elements from
4
- another `view`, or an empty range if the adapted `view` contains fewer
5
- than N elements.
6
 
7
  The name `views::drop` denotes a range adaptor object
8
  [[range.adaptor.object]]. Let `E` and `F` be expressions, let `T` be
9
  `remove_cvref_t<decltype((E))>`, and let `D` be
10
  `range_difference_t<decltype((E))>`. If `decltype((F))` does not model
11
  `convertible_to<D>`, `views::drop(E, F)` is ill-formed. Otherwise, the
12
  expression `views::drop(E, F)` is expression-equivalent to:
13
 
14
- - If `T` is a specialization of `ranges::empty_view`
15
- [[range.empty.view]], then `((void) F, decay-copy(E))`.
 
16
  - Otherwise, if `T` models `random_access_range` and `sized_range` and
17
  is
18
- - a specialization of `span` [[views.span]] where
19
- `T::extent == dynamic_extent`,
20
  - a specialization of `basic_string_view` [[string.view]],
21
- - a specialization of `ranges::iota_view` [[range.iota.view]], or
22
- - a specialization of `ranges::subrange` [[range.subrange]],
 
23
 
24
  then
25
- `T{ranges::begin(E) + min<D>(ranges::size(E), F), ranges::end(E)}`,
26
- except that `E` is evaluated only once.
27
- - Otherwise, `ranges::drop_view{E, F}`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  [*Example 1*:
30
 
31
  ``` cpp
32
  auto ints = views::iota(0) | views::take(10);
33
- auto latter_half = drop_view{ints, 5};
34
- for (auto i : latter_half) {
35
  cout << i << ' '; // prints 5 6 7 8 9
36
  }
37
  ```
38
 
39
  — *end example*]
 
1
  #### Overview <a id="range.drop.overview">[[range.drop.overview]]</a>
2
 
3
+ `drop_view` produces a view excluding the first N elements from another
4
+ view, or an empty range if the adapted view contains fewer than N
5
+ elements.
6
 
7
  The name `views::drop` denotes a range adaptor object
8
  [[range.adaptor.object]]. Let `E` and `F` be expressions, let `T` be
9
  `remove_cvref_t<decltype((E))>`, and let `D` be
10
  `range_difference_t<decltype((E))>`. If `decltype((F))` does not model
11
  `convertible_to<D>`, `views::drop(E, F)` is ill-formed. Otherwise, the
12
  expression `views::drop(E, F)` is expression-equivalent to:
13
 
14
+ - If `T` is a specialization of `empty_view` [[range.empty.view]], then
15
+ `((void)F, decay-copy(E))`, except that the evaluations of `E` and `F`
16
+ are indeterminately sequenced.
17
  - Otherwise, if `T` models `random_access_range` and `sized_range` and
18
  is
19
+ - a specialization of `span` [[views.span]],
 
20
  - a specialization of `basic_string_view` [[string.view]],
21
+ - a specialization of `iota_view` [[range.iota.view]], or
22
+ - a specialization of `subrange` [[range.subrange]] where
23
+ `T::StoreSize` is `false`,
24
 
25
  then
26
+ `U(ranges::begin(E) + std::min<D>(ranges::distance(E), F), ranges::end(E))`,
27
+ except that `E` is evaluated only once, where `U` is
28
+ `span<typename T::element_type>` if `T` is a specialization of `span`
29
+ and `T` otherwise.
30
+ - Otherwise, if `T` is a specialization of `subrange` [[range.subrange]]
31
+ that models `random_access_range` and `sized_range`, then
32
+ `T(ranges::begin(E) + std::min<D>(ranges::distance(E), F), ranges::{}end(E),
33
+ to-unsigned-like(ranges::distance(E) -
34
+ std::min<D>(ranges::distance(E), F)))`, except that `E` and `F` are
35
+ each evaluated only once.
36
+ - Otherwise, if `T` is a specialization of `repeat_view`
37
+ [[range.repeat.view]]:
38
+ - if `T` models `sized_range`, then
39
+ ``` cpp
40
+ views::repeat(*E.value_, ranges::distance(E) - std::min<D>(ranges::distance(E), F))
41
+ ```
42
+
43
+ except that `E` is evaluated only once;
44
+ - otherwise, `((void)F, decay-copy(E))`, except that the evaluations
45
+ of `E` and `F` are indeterminately sequenced.
46
+ - Otherwise, `drop_view(E, F)`.
47
 
48
  [*Example 1*:
49
 
50
  ``` cpp
51
  auto ints = views::iota(0) | views::take(10);
52
+ for (auto i : ints | views::drop(5)) {
 
53
  cout << i << ' '; // prints 5 6 7 8 9
54
  }
55
  ```
56
 
57
  — *end example*]