@@ -165,17 +165,21 @@ See_Also:
165165
166166Params:
167167 R = type to be tested
168+ E = the type of the elements of the range if not `void`
168169
169170Returns:
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
171172 */
172- enum bool isInputRange(R) =
173+ enum bool isInputRange(R, E = void ) =
173174 is (typeof (R.init) == R)
174175 && is (typeof ((R r) { return r.empty; } (R.init)) == bool )
175176 && (is (typeof ((return ref R r) => r.front)) || is (typeof (ref (return ref R r) => r.front)))
176177 && ! 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)));
179183// /
180184@safe unittest
181185{
@@ -192,6 +196,18 @@ enum bool isInputRange(R) =
192196 static assert ( isInputRange! (char []));
193197 static assert (! isInputRange! (char [4 ]));
194198 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 ));
195211
196212 static struct NotDefaultConstructible
197213 {
0 commit comments