View source code
Display the source code in std/range/primitives.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Template std.range.primitives.isInfinite

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:

struct MyInfiniteRange
{
    enum bool empty = false;
    ...
}

Arguments

template isInfinite(R);

Example

import std.range : Repeat;
static assert(!isInfinite!(int[]));
static assert( isInfinite!(Repeat!(int)));
}

/**
Returns <code class="lang-d"><span class="kwd">true</span></code> if <code class="lang-d"><span class="pln">R</span></code> offers a slicing operator with integral boundaries
that returns a forward range type.

For finite ranges, the result of <code class="lang-d"><span class="pln">opSlice</span></code> must be of the same type as the
original range type. If the range defines <code class="lang-d"><span class="pln">opDollar</span></code>, then it must support
subtraction.

For infinite ranges, when <i>not</i> using <code class="lang-d"><span class="pln">opDollar</span></code>, the result of
<code class="lang-d"><span class="pln">opSlice</span></code> must be the result of <code class="lang-d"><span class="pln">take</span></code> or <code class="lang-d"><span class="pln">takeExactly</span></code> on the
original range (they both return the same type for infinite ranges). However,
when using <code class="lang-d"><span class="pln">opDollar</span></code>, the result of <code class="lang-d"><span class="pln">opSlice</span></code> must be that of the
original range type.

The following expression must be true for `hasSlicing` to be `true`:

isForwardRange!R && !isNarrowString!R && is(ReturnType!((R r) => r[1 .. 1].length) == size_t) && (is(typeof(lvalueOf!R[1 .. 1]) == R) || isInfinite!R) && (!is(typeof(lvalueOf!R[0 .. $])) || is(typeof(lvalueOf!R[0 .. $]) == R)) && (!is(typeof(lvalueOf!R[0 .. $])) || isInfinite!R || is(typeof(lvalueOf!R[0 .. $ - 1]) == R)) && is(typeof((ref R r) { static assert(isForwardRange!(typeof(r[1 .. 2])));

Authors

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

License

Boost License 1.0.

Comments