View source code
					
 Display the source code in std/range/primitives.d from which this page was generated on
 github.
					
				
				
 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.
					
				
				
 Page wiki
					
 View or edit the community-maintained wiki page associated with this page.
					
				
			
			Enum std.range.primitives.member isInputRange
			Returns true if R is an input range. An input range must
define the primitives emptypopFrontfront
R r; // can define a range object if (r.empty) {} // can test for empty r.popFront(); // can invoke popFront() auto h = r.front; // can get the front of the range of non-void type
The semantics of an input range (not checkable during compilation) are
assumed to be the following (r is an object of type R):
- r.emptyreturns- falseiff there is more data available in the range.
- r.frontreturns the current element in the range. It may return by value or by reference. Calling- r.frontis allowed only if calling- r.emptyhas, or would have, returned- false.
- r.popFrontadvances to the next element in the range. Calling- r.popFrontis allowed only if calling- r.emptyhas, or would have, returned- false.
Declaration
enum isInputRange(R) = is(typeof((inout int = 0)
{
R r = R.init;
if (r.empty)
{
}
r.popFront();
auto h = r.front;
}
));
					Parameters
| Name | Description | 
|---|---|
| R | type to be tested | 
Returns
true if R is an InputRange, false if not
Example
struct A {}
struct B
{
    void popFront();
    @property bool empty();
    @property int front();
}
static assert(!isInputRange!A);
static assert( isInputRange!B);
static assert( isInputRange!(int[]));
static assert( isInputRange!(char[]));
static assert(!isInputRange!(char[4]));
static assert( isInputRange!(inout(int)[]));
Authors
Andrei Alexandrescu, David Simcha, and Jonathan M Davis. Credit for some of the ideas in building this module goes to Leonardo Maffi.