xtd 1.0.0
Loading...
Searching...
No Matches
where_view.hpp
Go to the documentation of this file.
1
4#pragma once
5
8#include "../../iterable.hpp"
9#include "../../string.hpp"
10#include "../../views/views.hpp"
11
13namespace xtd {
15 namespace ranges {
17 namespace views {
37 class where_view {
38 template<typename predicate_t>
39 struct with_predicate {
40 const predicate_t& predicate;
41
42 template <xtd::iterable iterable_t>
43 auto operator()(iterable_t&& source) const {return xtd::linq::enumerable::as_enumerable(std::forward<iterable_t>(source)).where(predicate);}
44
45 template <xtd::iterable iterable_t>
46 friend auto operator |(iterable_t&& source, const with_predicate& self) {return self(std::forward<iterable_t>(source));}
47 };
48
49 public:
51
57 template <xtd::iterable iterable_t, typename predicate_t>
58 auto operator()(iterable_t&& source, const predicate_t& predicate) const {return xtd::linq::enumerable::from(std::forward<iterable_t>(source)).where(predicate);}
62 template<typename predicate_t>
63 auto operator()(const predicate_t& predicate) const {return with_predicate {predicate};}
64
76 template <xtd::iterable iterable_t>
77 friend auto operator |(iterable_t&& source, const where_view& view) {return view(std::forward<iterable_t>(source));}
79 };
80 }
81 }
82}
static auto from(source_t &&source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
static auto as_enumerable(source_t &&source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
The xtd::ranges::views::where_view class is used to filter elements from a sequence.
Definition where_view.hpp:37
friend auto operator|(iterable_t &&source, const where_view &view)
Applies a filter on the given range using the pipe operator.
Definition where_view.hpp:77
auto operator()(const predicate_t &predicate) const
Filters a sequence of values based on a predicate.
Definition where_view.hpp:63
auto operator()(iterable_t &&source, const predicate_t &predicate) const
Filters a sequence of values based on a predicate.
Definition where_view.hpp:58
xtd::func< bool, type_t > predicate
Represents a delegate that defines a set of criteria and determines whether the specified object meet...
Definition predicate.hpp:16
Contains xtd::istringable interface.
Contains xtd::iterable concept.
Contains xtd::linq::enumerable <type_t> class.
The view namesapce contains range views, lightweight objects that indirectly represent iterable seque...
Definition distinct.hpp:20
The ranges namespace is an extension and generalization of the xtd::linq that makes them more powerfu...
Definition distinct.hpp:18
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::string alias.
Contains xtd::views alias namespace.