tmp/tmpc_7400i4/{from.md → to.md}
RENAMED
|
@@ -1,24 +1,24 @@
|
|
| 1 |
### Drop while view <a id="range.drop.while">[[range.drop.while]]</a>
|
| 2 |
|
| 3 |
#### Overview <a id="range.drop.while.overview">[[range.drop.while.overview]]</a>
|
| 4 |
|
| 5 |
-
Given a unary predicate `pred` and a
|
| 6 |
-
produces a
|
| 7 |
`ranges::end(r)`).
|
| 8 |
|
| 9 |
The name `views::drop_while` denotes a range adaptor object
|
| 10 |
[[range.adaptor.object]]. Given subexpressions `E` and `F`, the
|
| 11 |
expression `views::drop_while(E, F)` is expression-equivalent to
|
| 12 |
-
`drop_while_view
|
| 13 |
|
| 14 |
[*Example 1*:
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
-
constexpr auto source = " \t \t \t hello there";
|
| 18 |
auto is_invisible = [](const auto x) { return x == ' ' || x == '\t'; };
|
| 19 |
-
auto skip_ws =
|
| 20 |
for (auto c : skip_ws) {
|
| 21 |
cout << c; // prints hello there with no leading space
|
| 22 |
}
|
| 23 |
```
|
| 24 |
|
|
@@ -31,35 +31,34 @@ namespace std::ranges {
|
|
| 31 |
template<view V, class Pred>
|
| 32 |
requires input_range<V> && is_object_v<Pred> &&
|
| 33 |
indirect_unary_predicate<const Pred, iterator_t<V>>
|
| 34 |
class drop_while_view : public view_interface<drop_while_view<V, Pred>> {
|
| 35 |
public:
|
| 36 |
-
drop_while_view() = default;
|
| 37 |
-
constexpr drop_while_view(V base, Pred pred);
|
| 38 |
|
| 39 |
constexpr V base() const & requires copy_constructible<V> { return base_; }
|
| 40 |
constexpr V base() && { return std::move(base_); }
|
| 41 |
|
| 42 |
constexpr const Pred& pred() const;
|
| 43 |
|
| 44 |
constexpr auto begin();
|
| 45 |
|
| 46 |
-
constexpr auto end()
|
| 47 |
-
{ return ranges::end(base_); }
|
| 48 |
|
| 49 |
private:
|
| 50 |
V base_ = V(); // exposition only
|
| 51 |
-
|
| 52 |
};
|
| 53 |
|
| 54 |
template<class R, class Pred>
|
| 55 |
drop_while_view(R&&, Pred) -> drop_while_view<views::all_t<R>, Pred>;
|
| 56 |
}
|
| 57 |
```
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
-
constexpr drop_while_view(V base, Pred pred);
|
| 61 |
```
|
| 62 |
|
| 63 |
*Effects:* Initializes *base\_* with `std::move(base)` and *pred\_* with
|
| 64 |
`std::move(pred)`.
|
| 65 |
|
|
@@ -71,11 +70,13 @@ constexpr const Pred& pred() const;
|
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
constexpr auto begin();
|
| 74 |
```
|
| 75 |
|
| 76 |
-
*
|
|
|
|
|
|
|
| 77 |
|
| 78 |
*Remarks:* In order to provide the amortized constant-time complexity
|
| 79 |
required by the `range` concept when `drop_while_view` models
|
| 80 |
`forward_range`, the first call caches the result within the
|
| 81 |
`drop_while_view` for use on subsequent calls.
|
|
|
|
| 1 |
### Drop while view <a id="range.drop.while">[[range.drop.while]]</a>
|
| 2 |
|
| 3 |
#### Overview <a id="range.drop.while.overview">[[range.drop.while.overview]]</a>
|
| 4 |
|
| 5 |
+
Given a unary predicate `pred` and a view `r`, `drop_while_view`
|
| 6 |
+
produces a view of the range \[`ranges::find_if_not(r, pred)`,
|
| 7 |
`ranges::end(r)`).
|
| 8 |
|
| 9 |
The name `views::drop_while` denotes a range adaptor object
|
| 10 |
[[range.adaptor.object]]. Given subexpressions `E` and `F`, the
|
| 11 |
expression `views::drop_while(E, F)` is expression-equivalent to
|
| 12 |
+
`drop_while_view(E, F)`.
|
| 13 |
|
| 14 |
[*Example 1*:
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
+
constexpr auto source = " \t \t \t hello there"sv;
|
| 18 |
auto is_invisible = [](const auto x) { return x == ' ' || x == '\t'; };
|
| 19 |
+
auto skip_ws = views::drop_while(source, is_invisible);
|
| 20 |
for (auto c : skip_ws) {
|
| 21 |
cout << c; // prints hello there with no leading space
|
| 22 |
}
|
| 23 |
```
|
| 24 |
|
|
|
|
| 31 |
template<view V, class Pred>
|
| 32 |
requires input_range<V> && is_object_v<Pred> &&
|
| 33 |
indirect_unary_predicate<const Pred, iterator_t<V>>
|
| 34 |
class drop_while_view : public view_interface<drop_while_view<V, Pred>> {
|
| 35 |
public:
|
| 36 |
+
drop_while_view() requires default_initializable<V> && default_initializable<Pred> = default;
|
| 37 |
+
constexpr explicit drop_while_view(V base, Pred pred);
|
| 38 |
|
| 39 |
constexpr V base() const & requires copy_constructible<V> { return base_; }
|
| 40 |
constexpr V base() && { return std::move(base_); }
|
| 41 |
|
| 42 |
constexpr const Pred& pred() const;
|
| 43 |
|
| 44 |
constexpr auto begin();
|
| 45 |
|
| 46 |
+
constexpr auto end() { return ranges::end(base_); }
|
|
|
|
| 47 |
|
| 48 |
private:
|
| 49 |
V base_ = V(); // exposition only
|
| 50 |
+
movable-box<Pred> pred_; // exposition only
|
| 51 |
};
|
| 52 |
|
| 53 |
template<class R, class Pred>
|
| 54 |
drop_while_view(R&&, Pred) -> drop_while_view<views::all_t<R>, Pred>;
|
| 55 |
}
|
| 56 |
```
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
+
constexpr explicit drop_while_view(V base, Pred pred);
|
| 60 |
```
|
| 61 |
|
| 62 |
*Effects:* Initializes *base\_* with `std::move(base)` and *pred\_* with
|
| 63 |
`std::move(pred)`.
|
| 64 |
|
|
|
|
| 70 |
|
| 71 |
``` cpp
|
| 72 |
constexpr auto begin();
|
| 73 |
```
|
| 74 |
|
| 75 |
+
*Preconditions:* *`pred_`*`.has_value()` is `true`.
|
| 76 |
+
|
| 77 |
+
*Returns:* `ranges::find_if_not(`*`base_`*`, cref(*`*`pred_`*`))`.
|
| 78 |
|
| 79 |
*Remarks:* In order to provide the amortized constant-time complexity
|
| 80 |
required by the `range` concept when `drop_while_view` models
|
| 81 |
`forward_range`, the first call caches the result within the
|
| 82 |
`drop_while_view` for use on subsequent calls.
|