|
| class | Generator |
| | Generator that C++20 coroutines passed to CXXIter::IterApi::generateFrom() have to return. This generator supports exceptions, co_yield for producing an arbitrary amount of elements, and can take references as results from coroutines - as long as they live long enough until used. More...
|
| |
| class | IterApi |
| | Public Iterator API surface. More...
|
| |
| class | IterValue |
| | Container that is used to pass elements through CXXIter's iterator pipelines. More...
|
| |
| struct | SizeHint |
| | Structure holding the bounds of a CXXIter iterator's estimated length. More...
|
| |
| class | SrcCRef |
| | CXXIter iterator source that immutably borrows the input item source, and passes immutable references to the items of the source through the iterator. More...
|
| |
| class | SrcMov |
| | CXXIter iterator source that takes over the input item source, and moves its items through the element stream, essentially "consuming" them. More...
|
| |
| class | SrcRef |
| | CXXIter iterator source that mutably borrows the input item source, and passes mutable references to the items of the source through the iterator. More...
|
| |
|
|
template<typename TContainer >
requires (!std::is_reference_v<TContainer> && !util::is_const_reference_v<TContainer> && concepts::SourceContainer<TContainer>) |
| constexpr SrcMov< std::remove_cvref_t< TContainer > > | from (TContainer &&container) |
| | Construct a CXXIter move source from the given container. More...
|
| |
template<typename TContainer >
requires (!std::is_reference_v<TContainer> && !util::is_const_reference_v<TContainer> && concepts::SourceContainer<TContainer>) |
| constexpr SrcRef< std::remove_cvref_t< TContainer > > | from (TContainer &container) |
| | Construct a CXXIter mutable-reference source from the given container. More...
|
| |
template<typename TContainer >
requires (!std::is_reference_v<TContainer> && !util::is_const_reference_v<TContainer> && concepts::SourceContainer<TContainer>) |
| constexpr SrcCRef< std::remove_cvref_t< TContainer > > | from (const TContainer &container) |
| | Construct a CXXIter const-reference source from the given container. More...
|
| |
|
| template<typename TItem > |
| constexpr Empty< TItem > | empty () |
| | Constructs an empty iterator yielding no items. More...
|
| |
template<std::invocable<> TGeneratorFn>
requires util::is_optional<std::invoke_result_t<TGeneratorFn>> |
| constexpr auto | fromFn (TGeneratorFn generatorFn) |
| | Generator source that takes a generatorFn, each invocation of which produces one element for the resulting iterator. More...
|
| |
| template<GeneratorFunction TGeneratorFn> |
| auto | generate (TGeneratorFn generatorFn) |
| | Generator source that produces a new iterator over the elements produced by the given generatorFn - which is a c++20 coroutine yielding elements using co_yield. More...
|
| |
| template<typename TItem > |
| constexpr Repeater< TItem > | repeat (const TItem &item, std::optional< size_t > cnt={}) |
| | Construct a CXXIter iterator, by repeating the given item cnt times. More...
|
| |
| template<typename TValue > |
| constexpr Range< TValue > | range (TValue from, TValue to, TValue step=1) |
| | Construct a CXXIter iterator that yields all elements in the range between [from, to] (inclusive both edges), using the given step between elements. More...
|
| |
template<typename TContainer >
requires (!std::is_reference_v<TContainer> && !util::is_const_reference_v<TContainer> && concepts::SourceContainer<TContainer>)
| constexpr SrcCRef< std::remove_cvref_t< TContainer > > CXXIter::from |
( |
const TContainer & |
container | ) |
|
|
constexpr |
Construct a CXXIter const-reference source from the given container.
This constructs a const-reference source. This guarantees the given container to stay untouched.
- Parameters
-
| container | Container to construct a CXXIter source from. |
- Returns
- CXXIter const-reference source from the given container.
Definition at line 2214 of file CXXIter.h.
template<typename TContainer >
requires (!std::is_reference_v<TContainer> && !util::is_const_reference_v<TContainer> && concepts::SourceContainer<TContainer>)
| constexpr SrcMov< std::remove_cvref_t< TContainer > > CXXIter::from |
( |
TContainer && |
container | ) |
|
|
constexpr |
Construct a CXXIter move source from the given container.
This constructs a move source, which will move the items from the given container into the iterator.
- Parameters
-
| container | Container to construct a CXXIter source from. |
- Returns
- CXXIter move source from the given container.
Definition at line 2188 of file CXXIter.h.
template<typename TContainer >
requires (!std::is_reference_v<TContainer> && !util::is_const_reference_v<TContainer> && concepts::SourceContainer<TContainer>)
| constexpr SrcRef< std::remove_cvref_t< TContainer > > CXXIter::from |
( |
TContainer & |
container | ) |
|
|
constexpr |
Construct a CXXIter mutable-reference source from the given container.
This constructs a mutable-reference source. This allows the iterator to modify the elements in the given container.
- Parameters
-
| container | Container to construct a CXXIter source from. |
- Returns
- CXXIter mutable-reference source from the given container.
Definition at line 2201 of file CXXIter.h.
template<std::invocable<> TGeneratorFn>
requires util::is_optional<std::invoke_result_t<TGeneratorFn>>
| constexpr auto CXXIter::fromFn |
( |
TGeneratorFn |
generatorFn | ) |
|
|
constexpr |
Generator source that takes a generatorFn, each invocation of which produces one element for the resulting iterator.
- Parameters
-
| generatorFn | Generator that returns an optional value. If the optional is None, the resulting iterator ends. |
- Returns
- CXXIter iterator whose elements are produced by the calls to the given
generatorFn.
You could for example also use this to pull messages from a socket.
Usage Example:
- Simple endless generator producing monotonically increasing numbers
size_t generatorState = 0;
std::function<std::optional<size_t>()> generatorFn = [generatorState]() mutable {
return (generatorState++);
};
.take(100)
.collect<std::vector>();
constexpr auto fromFn(TGeneratorFn generatorFn)
Generator source that takes a generatorFn, each invocation of which produces one element for the resu...
Definition at line 2261 of file CXXIter.h.