xtd 0.2.0
Loading...
Searching...
No Matches
where_view.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#define __XTD_STD_INTERNAL__
8#undef __XTD_STD_INTERNAL__
10#include "../../istringable.hpp"
11#include "../../string.hpp"
12#include "../../views/views.hpp"
13
15#if defined(__xtd__cpp_lib_ranges)
17#include <ranges>
18
20namespace xtd {
22 namespace ranges {
24 namespace views {
39 class where_view {
40 template <typename predicate_t>
41 struct with_predicate {
42 const predicate_t& predicate;
43
44 template <std::ranges::range range_t>
45 auto operator()(range_t&& source) const {return xtd::linq::enumerable::as_enumerable(std::forward<range_t>(source)).where(predicate);}
46
47 template <std::ranges::range range_t>
48 friend auto operator |(range_t&& source, const with_predicate& self) {return self(std::forward<range_t>(source));}
49 };
50
51 public:
53
59 template <std::ranges::range range_t, typename predicate_t>
60 auto operator()(range_t&& source, const predicate_t& predicate) const {return xtd::linq::enumerable::from(std::forward<range_t>(source)).where(predicate);}
64 template <typename predicate_t>
65 auto operator()(const predicate_t& predicate) const {return with_predicate {predicate};}
66
78 template <std::ranges::range range_type>
79 friend auto operator |(range_type&& source, const where_view& view) {return view(std::forward<range_type>(source));}
81 };
82 }
83 }
84}
86#endif
Contains __xtd_std_version definitions.
static const auto & as_enumerable(const ienumerable< source_t > &source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:286
static const auto & from(const ienumerable< source_t > &source) noexcept
Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
Definition enumerable.hpp:651
The xtd::ranges::views::where_view class is used to filter elements from a sequence.
Definition where_view.hpp:39
auto operator()(const predicate_t &predicate) const
Filters a sequence of values based on a predicate.
Definition where_view.hpp:65
friend auto operator|(range_type &&source, const where_view &view)
Applies a filter on the given range using the pipe operator.
Definition where_view.hpp:79
auto operator()(range_t &&source, const predicate_t &predicate) const
Filters a sequence of values based on a predicate.
Definition where_view.hpp:60
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::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.