tmp/tmpqi_4s_ve/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Class template `filter_view` <a id="range.filter.view">[[range.filter.view]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std::ranges {
|
| 5 |
+
template<input_range V, indirect_unary_predicate<iterator_t<V>> Pred>
|
| 6 |
+
requires view<V> && is_object_v<Pred>
|
| 7 |
+
class filter_view : public view_interface<filter_view<V, Pred>> {
|
| 8 |
+
private:
|
| 9 |
+
V base_ = V(); // exposition only
|
| 10 |
+
semiregular-box<Pred> pred_; // exposition only
|
| 11 |
+
|
| 12 |
+
// [range.filter.iterator], class filter_view::iterator
|
| 13 |
+
class iterator; // exposition only
|
| 14 |
+
// [range.filter.sentinel], class filter_view::sentinel
|
| 15 |
+
class sentinel; // exposition only
|
| 16 |
+
|
| 17 |
+
public:
|
| 18 |
+
filter_view() = default;
|
| 19 |
+
constexpr filter_view(V base, Pred pred);
|
| 20 |
+
|
| 21 |
+
constexpr V base() const& requires copy_constructible<V> { return base_; }
|
| 22 |
+
constexpr V base() && { return std::move(base_); }
|
| 23 |
+
|
| 24 |
+
constexpr const Pred& pred() const;
|
| 25 |
+
|
| 26 |
+
constexpr iterator begin();
|
| 27 |
+
constexpr auto end() {
|
| 28 |
+
if constexpr (common_range<V>)
|
| 29 |
+
return iterator{*this, ranges::end(base_)};
|
| 30 |
+
else
|
| 31 |
+
return sentinel{*this};
|
| 32 |
+
}
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
template<class R, class Pred>
|
| 36 |
+
filter_view(R&&, Pred) -> filter_view<views::all_t<R>, Pred>;
|
| 37 |
+
}
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
``` cpp
|
| 41 |
+
constexpr filter_view(V base, Pred pred);
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
*Effects:* Initializes *base\_* with `std::move(base)` and initializes
|
| 45 |
+
*pred\_* with `std::move(pred)`.
|
| 46 |
+
|
| 47 |
+
``` cpp
|
| 48 |
+
constexpr const Pred& pred() const;
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
*Effects:* Equivalent to: `return *`*`pred_`*`;`
|
| 52 |
+
|
| 53 |
+
``` cpp
|
| 54 |
+
constexpr iterator begin();
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
*Preconditions:* `pred_.has_value()`.
|
| 58 |
+
|
| 59 |
+
*Returns:* `{*this, ranges::find_if(`*`base_`*`, ref(*`*`pred_`*`))}`.
|
| 60 |
+
|
| 61 |
+
*Remarks:* In order to provide the amortized constant time complexity
|
| 62 |
+
required by the `range` concept when `filter_view` models
|
| 63 |
+
`forward_range`, this function caches the result within the
|
| 64 |
+
`filter_view` for use on subsequent calls.
|
| 65 |
+
|