December 14, 2012
> It works because "put" is defined for all input ranges as "write to first element and popFront".

That makes more sense, thanks.
So what happens is that for "regular" ranges std.range.put() gets used, while for arrays in RefAppender std.array.put() gets used, right?

(I noticed that the unittest fails if the destination char[] isn't empty.)

> The "problem" in this case is that you have to make sure *before hand*, that there is enough room to do this. If you were to "accidently" stuff into your input range more than it can take, you'll error out. EG. the same as going past it_end.

I think it's OK. The output MmFile is constructed to have the size of the input MmFile. So their opSlice's will have the same length.
December 14, 2012
On Friday, 14 December 2012 at 15:59:48 UTC, Mu wrote:
>> It works because "put" is defined for all input ranges as "write to first element and popFront".
>
> That makes more sense, thanks.
> So what happens is that for "regular" ranges std.range.put() gets used, while for arrays in RefAppender std.array.put() gets used, right?

Nope, you call the member function. std.array.RefAppender.put.

Link to how "put" resolves. http://dlang.org/phobos/std_range.html#put
1 2
Next ›   Last »