The OpenD Programming Language

isInputRange

ditto

  1. import std.traits;
  2. enum bool isInputRange(R, E);
    enum bool isInputRange(R, E);

Examples

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 static assert(!isInputRange!(int[], string));
15 static assert( isInputRange!(int[], int));
16 static assert( isInputRange!(int[], const int));
17 static assert(!isInputRange!(int[], immutable int));
18 
19 static assert(!isInputRange!(const(int)[], int));
20 static assert( isInputRange!(const(int)[], const int));
21 static assert(!isInputRange!(const(int)[], immutable int));
22 
23 static assert(!isInputRange!(immutable(int)[], int));
24 static assert( isInputRange!(immutable(int)[], const int));
25 static assert( isInputRange!(immutable(int)[], immutable int));
26 
27 static struct NotDefaultConstructible
28 {
29     @disable this();
30     void popFront();
31     @property bool empty();
32     @property int front();
33 }
34 static assert( isInputRange!NotDefaultConstructible);
35 
36 static struct NotDefaultConstructibleOrCopyable
37 {
38     @disable this();
39     @disable this(this);
40     void popFront();
41     @property bool empty();
42     @property int front();
43 }
44 static assert(isInputRange!NotDefaultConstructibleOrCopyable);
45 
46 static struct Frontless
47 {
48     void popFront();
49     @property bool empty();
50 }
51 static assert(!isInputRange!Frontless);
52 
53 static struct VoidFront
54 {
55     void popFront();
56     @property bool empty();
57     void front();
58 }
59 static assert(!isInputRange!VoidFront);

Meta