On Sunday, 9 June 2013 at 12:19:47 UTC, Lars T. Kyllingstad wrote:
A recent pull request discussion got me thinking: The ability to "downgrade" a range to a less featureful one -- wrapping a random access range in an input range, say -- can be very useful sometimes, particularly for testing. The pull request in question was Walter's LZ77 module,
[...]

One solution which has come up in the aforementioned pull request discussion (thanks to Daniel Murphy) is to downcast the result of std.range.inputRangeObject() to the desired interface.

   Intf!(ElementEncodingType!R) downgrade(alias Intf, R)(R rng)
   {
       return inputRangeObject(rng);
   }

   auto someInputRange = downgrade!InputRange(someRandAccRange);

Maybe this is good enough for testing purposes?

Reply via email to