true if R is an input range, false if not
1 struct A {} 2 struct B 3 { 4 void popFront(); 5 @property bool empty(); 6 @property int front(); 7 } 8 static assert(!isInputRange!A); 9 static assert( isInputRange!B); 10 static assert( isInputRange!(int[])); 11 static assert( isInputRange!(char[])); 12 static assert(!isInputRange!(char[4])); 13 static assert( isInputRange!(inout(int)[])); 14 15 static struct NotDefaultConstructible 16 { 17 @disable this(); 18 void popFront(); 19 @property bool empty(); 20 @property int front(); 21 } 22 static assert( isInputRange!NotDefaultConstructible); 23 24 static struct NotDefaultConstructibleOrCopyable 25 { 26 @disable this(); 27 @disable this(this); 28 void popFront(); 29 @property bool empty(); 30 @property int front(); 31 } 32 static assert(isInputRange!NotDefaultConstructibleOrCopyable); 33 34 static struct Frontless 35 { 36 void popFront(); 37 @property bool empty(); 38 } 39 static assert(!isInputRange!Frontless); 40 41 static struct VoidFront 42 { 43 void popFront(); 44 @property bool empty(); 45 void front(); 46 } 47 static assert(!isInputRange!VoidFront);
The header of std.range for tutorials on ranges.
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.
The following are rules of input ranges are assumed to hold true in all Phobos code. These rules are not checkable at compile-time, so not conforming to these rules when writing ranges or range based code will result in undefined behavior.
Also, note that Phobos code assumes that the primitives r.front and r.empty are O(1) time complexity wise or "cheap" in terms of running time. O() statements in the documentation of range functions are made with this assumption.