ae.utils.meta.tuplerange

Tuple ranges

Contains constructs for iterating and chaining together operations on range-like constructs which operate on heterogeneous types.

To allow heterogeneous elements, iteration is internal rather than external. The range elements are functors - calling a range with a function parameter "next" asks the range to iterate over its members and call "next" over each one. "next" returns a bool (true if iteration should stop, false if it should continue), which is propagated by the range's opCall upwards.

Members

Functions

trCTFilter
auto trCTFilter(R r)

Like trFilter, but evaluates pred at compile-time with each element's type.

trEach
auto trEach(R r)

Sink, calls predicate over each value in r. If predicate returns a boolean, use that to determine whether to stop or keep going.

trFilter
auto trFilter(R r)

Passes only values satisfying the given predicate to the next layer.

trFront
auto trFront(R r)

Calls predicate with only the first value in r.

trIter
auto trIter(R r)

Convert a regular (homogeneous) range to a tuple range.

trJoiner
auto trJoiner(R r)

r is a tuple range of tuple ranges. Process it as one big range.

trMap
auto trMap(R r)

Transforms values using the given predicate before passing them to the next layer.

trOnly
auto trOnly(T values)

Source, iterates over the given values.

Examples

int a = 2;
int offset = 1;
int x;
trOnly(0, 1., 2f)
	.trMap!(n => n + offset)
	.trFilter!(n => n > a)
	.trEach!((n) { x = cast(int)n; } );
assert(x == 3);

Meta

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Authors

Vladimir Panteleev <ae@cy.md>