Is this a bug? RandomSample claims it needs input range but actually needs forward range

finalpatch fengli at gmail.com
Tue Jun 18 18:56:43 PDT 2013


in the declaration of RandomSample it only checks for 
isInputRange, but in the implementation it calls the .save() 
method which is only available in forward ranges.

as a result this code does not compile:

void main()
{
	auto a = File("test.d", "r").byLine();
	auto s = randomSample(a,1,5);
	writeln(s);
}

Is this a bug or I missed something?


More information about the Digitalmars-d mailing list