www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Range.init does not imply Range.empty==true

I noticed that in some places in Phobos range-related code, there's an
assumption that the following code works:

	auto someRangeFunction(R)(R range) {
		...
		R helperRange = range;
		...
		helperRange = R.init;
		assert(helperRange.empty);
		...
	}

Exercise for the reader: spot the bug.

Hint: what if R is an InputRangeObject?


T

-- 
Which is worse: ignorance or apathy? Who knows? Who cares? -- Erich Schubert
Dec 20 2012