xtd 0.2.0
Loading...
Searching...
No Matches
xtd::ranges::views::where_view Class Reference

Definition

The xtd::ranges::views::where_view class is used to filter elements from a sequence.

Definition
class where_view;
The xtd::ranges::views::where_view class is used to filter elements from a sequence.
Definition where_view.hpp:44
Header
#include <xtd/ranges/views/where_view>
Namespace
xtd::ranges::views
Library
xtd.core
Examples
The following example shows how to use xtd::ranges::views::where instance :
#include <xtd/xtd>
auto main() -> int {
auto numbers = array {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
console::write_line("numbers = {}", numbers | where([](auto n) {return n <= 5;}));
}
// This code produces the following output :
//
// numbers = [1, 2, 3, 4, 5]
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:63
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
constexpr auto where
The xtd::ranges::views::where instance.
Definition where.hpp:40
@ n
The N key.
Definition console_key.hpp:114
The following example shows how to use xtd::ranges::views::where_view class :
#include <xtd/xtd>
auto main() -> int {
auto numbers = array {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
console::write_line("numbers = {}", where(numbers, [](auto n) {return n <= 5;}));
}
// This code produces the following output :
//
// numbers = [1, 2, 3, 4, 5]

Public Operators

template<std::ranges::range range_t, typename predicate_t>
auto operator() (range_t &&source, const predicate_t &predicate) const
 Filters a sequence of values based on a predicate.
 
template<typename predicate_t>
auto operator() (const predicate_t &predicate) const
 Filters a sequence of values based on a predicate.
 

Member Function Documentation

◆ operator()() [1/2]

template<std::ranges::range range_t, typename predicate_t>
auto xtd::ranges::views::where_view::operator() ( range_t && source,
const predicate_t & predicate ) const
inline

Filters a sequence of values based on a predicate.

Template Parameters
range_tThe type of the elements of source.
Parameters
sourceA sequence of values to filter.
predicateA function to test each element for a condition.

◆ operator()() [2/2]

template<typename predicate_t>
auto xtd::ranges::views::where_view::operator() ( const predicate_t & predicate) const
inline

Filters a sequence of values based on a predicate.

Template Parameters
range_tThe type of the elements of source.
Parameters
predicateA function to test each element for a condition.

The documentation for this class was generated from the following file: