mir.primitives

Templates used to check primitives and range primitives for arrays with multi-dimensional like API support.

Note: UTF strings behaves like common arrays in Mir. std.uni.byCodePoint can be used to create a range of characters.

Members

Aliases

DeepElementType
alias DeepElementType(S : T[], T) = T

Returns the element type of a struct with .DeepElement inner alias or a type of common array. Returns ForeachType if struct does not have .DeepElement member.

elementsCount
deprecated alias elementsCount = elementCount
Undocumented in source.

Functions

anyEmpty
bool anyEmpty(Range range)
anyEmptyShape
bool anyEmptyShape(size_t[N] shape)
Undocumented in source. Be warned that the author may not have intended to support it.
back
inout(T) back(inout(T)[] ar)
elementCount
size_t elementCount(Range range)
empty
bool empty(T[] ar)
front
inout(T) front(inout(T)[] ar)
length
size_t length(T[] array)
popBack
void popBack(inout(T)[] ar)
popBackExactly
void popBackExactly(inout(T)[] ar, size_t n)
popBackN
size_t popBackN(inout(T)[] ar, size_t n)
popFront
void popFront(inout(T)[] ar)
popFrontExactly
void popFrontExactly(inout(T)[] ar, size_t n)
popFrontN
size_t popFrontN(inout(T)[] ar, size_t n)
save
inout(T)[] save(inout(T)[] array)
shape
auto shape(Range range)
walkLength
auto walkLength(Range range)

This is a best-effort implementation of length for any kind of range. If hasLength!Range, simply returns range.length without checking upTo (when specified). Otherwise, walks the range through its length and returns the number of elements seen. Performes O(n) evaluations of range.empty and range.popFront(), where n is the effective length of range.

Templates

DeepElementType
template DeepElementType(S)

Returns the element type of a struct with .DeepElement inner alias or a type of common array. Returns ForeachType if struct does not have .DeepElement member.

DimensionCount
template DimensionCount(T)
ElementType
template ElementType(R)

The element type of R. R does not have to be a range. The element type is determined as the type yielded by r.front for an object r of type R. For example, ElementType!(T[]) is T if T[] isn't a narrow string; if it is, the element type is dchar. If R doesn't have front, ElementType!R is void.

isInfinite
template isInfinite(R)

Returns true if R is an infinite input range. An infinite input range is an input range that has a statically-defined enumerated member called empty that is always false, for example:

Variables

hasLength
enum bool hasLength(R);
hasShape
enum bool hasShape(R);
isInputRange
enum bool isInputRange(R);

Returns true if R is an input range. An input range must define the primitives empty, popFront, and front. The following code should compile for any input range.

isOutputRange
enum bool isOutputRange(R, E);

Returns true if R is an output range for elements of type E. An output range is defined functionally as a range that supports the operation r.put(e).

Meta

License

Apache-2.0

Authors

Ilya Yaroshenko, Andrei Alexandrescu, David Simcha, and Jonathan M Davis. Credit for some of the ideas in building this module goes to Leonardo Maffi