Phobos Proposal: replace std.xml with kxml.

Robert Jacques sandford at jhu.edu
Tue May 4 21:05:49 PDT 2010


On Tue, 04 May 2010 21:55:53 -0400, Michel Fortin  
<michel.fortin at michelf.com> wrote:
> 	// String version: can slice
> 	string readUntil(isAtEndPredicate)(ref string input) {
> 		string savedInput;
> 		while (!input.empty && isAtEndPredicate(input.front)) {
> 			input.popFront();
> 		}
> 		return savedInput[0..$-input.length];
> 	}

What about using forward ranges and take?

	// String version: can slice
	Take!T readUntil(isAtEndPredicate, T)(ref T input) if(isForwardRange!T) {
		auto savedInput = input;
                 size_t n = 0;
		while (!input.empty && isAtEndPredicate(input.front)) {
			input.popFront();
                         n++;
		}
		return take(savedInput,n);
	}


More information about the Digitalmars-d mailing list