@@ -165,17 +165,21 @@ See_Also:
165
165
166
166
Params:
167
167
R = type to be tested
168
+ E = the type of the elements of the range if not `void`
168
169
169
170
Returns:
170
- `true` if R is an input range, `false` if not
171
+ `true` if R is an input range (possibly with element type `E`) , `false` if not
171
172
*/
172
- enum bool isInputRange(R) =
173
+ enum bool isInputRange(R, E = void ) =
173
174
is (typeof (R.init) == R)
174
175
&& is (typeof ((R r) { return r.empty; } (R.init)) == bool )
175
176
&& (is (typeof ((return ref R r) => r.front)) || is (typeof (ref (return ref R r) => r.front)))
176
177
&& ! is (typeof ((R r) { return r.front; } (R.init)) == void )
177
- && is (typeof ((R r) => r.popFront));
178
-
178
+ && is (typeof ((R r) => r.popFront))
179
+ && (is (E == void ) ||
180
+ is (ElementType! R == E) ||
181
+ is (const (ElementType! R) == E) ||
182
+ (is (const (ElementType! R) == immutable E) && is (const (E) == E)));
179
183
// /
180
184
@safe unittest
181
185
{
@@ -192,6 +196,18 @@ enum bool isInputRange(R) =
192
196
static assert ( isInputRange! (char []));
193
197
static assert (! isInputRange! (char [4 ]));
194
198
static assert ( isInputRange! (inout (int )[]));
199
+ static assert (! isInputRange! (int [], string ));
200
+ static assert ( isInputRange! (int [], int ));
201
+ static assert ( isInputRange! (int [], const int ));
202
+ static assert (! isInputRange! (int [], immutable int ));
203
+
204
+ static assert (! isInputRange! (const (int )[], int ));
205
+ static assert ( isInputRange! (const (int )[], const int ));
206
+ static assert (! isInputRange! (const (int )[], immutable int ));
207
+
208
+ static assert (! isInputRange! (immutable (int )[], int ));
209
+ static assert ( isInputRange! (immutable (int )[], const int ));
210
+ static assert ( isInputRange! (immutable (int )[], immutable int ));
195
211
196
212
static struct NotDefaultConstructible
197
213
{
0 commit comments