What's the definition of InputRange? Is it the interface from std.range? If so, don't pass it as ref. interfaces are references to the object by default. In general, you only need ref when you want to assign a new object to the variable and want that change to be seen outside the function too.