xtd 0.2.0
Loading...
Searching...
No Matches
select_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 {
40 template <typename selector_t>
41 struct with_selector {
42 const selector_t& selector;
43
44 template <std::ranges::range range_t>
45 auto operator()(range_t&& source) const {return xtd::linq::enumerable::from(std::forward<range_t>(source)).select(selector);}
46
47 template <std::ranges::range range_t>
48 friend auto operator |(range_t&& source, const with_selector& self) {return self(std::forward<range_t>(source));}
49 };
50
51 public:
53
59 template <std::ranges::range range_t, typename selector_t>
60 auto operator()(range_t&& source, const selector_t& selector) const {return xtd::linq::enumerable::as_enumerable(std::forward<range_t>(source)).select(selector);}
64 template <typename selector_t>
65 auto operator()(const selector_t& selector) const {return with_selector {selector};}
66
78 template <std::ranges::range range_type>
79 friend auto operator |(range_type&& source, const select_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::select_view class is used to select elements from a sequence.
Definition select_view.hpp:39
friend auto operator|(range_type &&source, const select_view &view)
Applies a select projection on the given range using the pipe operator.
Definition select_view.hpp:79
auto operator()(range_t &&source, const selector_t &selector) const
Projects each element of a sequence into a new form.
Definition select_view.hpp:60
auto operator()(const selector_t &selector) const
Projects each element of a sequence into a new form.
Definition select_view.hpp:65
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.