xtd 0.2.0
Loading...
Searching...
No Matches
xtd::forward_iterable< value_t > Struct Template Reference

Definition

template<class value_t>
struct xtd::forward_iterable< value_t >

Represents the forward iterable concept.

Definition
template<class value_t>
Definition forward_iterable.hpp:18
Header
#include <xtd/forward_iterable>
Namespace
xtd
Library
xtd.core
Examples
The following code shows how to use xtd::forward_iterable concept
#include <xtd/xtd>
auto int_generator() -> enumerable_generator<int> {
co_yield 15;
co_yield 11;
co_yield 13;
co_yield 14;
co_yield 12;
}
template <forward_iterable iterable_t>
[[nodiscard]] auto iterate(iterable_t&& iterable) -> enumerable_generator<forward_iterable_value_type<iterable_t>> {
for (const auto& item : iterable)
co_yield item;
}
auto main() -> int {
for (auto item : iterate(std::vector {5, 1, 3, 4, 2}).select([](auto v) {return v * 2;}).order())
println("{,2}", item);
for (auto item : iterate(list {10, 6, 8, 9, 7}).select([](auto v) {return v * 3;}).order())
println("{,2}", item);
for (auto item : iterate(int_generator()).select([](auto v) {return v * 4;}).order())
println("{,2}", item);
}
// This code produces the following output :
//
// 2
// 4
// 6
// 8
// 10
// 18
// 21
// 24
// 27
// 30
// 44
// 48
// 52
// 56
// 60
constexpr auto select
The xtd::ranges::views::select instance.
Definition select.hpp:40
@ v
The V key.
Definition console_key.hpp:130
void println(FILE *file)
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:14

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