Thanks to Philippe Sigaud for the proposed solution. It was helpful.
The former implementation simply used input.back for Take.back. It didn't work if input.length was larger than maxAvailable. For example:
input = [ 1, 2, 3, 4, 5 ]
s = take(input, 3) // [ 1, 2, 3 ]
s.back == input.back == 5 // wrong!
Take must pop all the excess elements from the input ([4,5] in the above example) to provide correct back element. This change makes it to do so if input is purely bidirectional. (random access is used instead if possible.)
- Added Take.opSlice
- Added some enforcement error messages
std.algorithm: defined move with one argument; levenshtein distance generalized to with all forward ranges; take now has swapped arguments
std.array: empty for arrays is now a @property; front and back for a string and wstring automatically decodes the first/last character; popFront, popBack for string and wstring obey the UTF stride
std.conv: changed the default array formatting from "[a, b, c]" to "a b c"
std.range: swapped order of arguments in take
std.stdio: added readln template
std.variant: now works with statically-sized arrays and const data
std.traits: added isNarrowString