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 unitte
It "works" because in theory, all mutable ranges verify the "is
output range" trait. However, they are not "sinks", so if you
write too much into them, you'll get an out of index exception.
Does it work at runtime, and do you get the correct behavior?
From what I tested, yes it works correctly
Thank you, monarch_dodra. This looks like what I wanted.
I have a question:
How come the function works with MmFile.opSlice's without
appender(&)?
And is this reliable behavior?
caesarCipher(cast(ubyte[]) inputFile.opSlice, cast(ubyte[])
outputFile.opSlice, 13);
Trying to use appender(&) on
Thank you for your suggestion, bearophile.
I ended up checking if the range is empty, and if it was, I'd
increment it as elements were added.
Honestly, I much dislike this method.
It does not feel right. The C++ version is more consistent
because of the iterators.
Please, if anyone has a bet
foreach (i, ref o; output)
But isn't output empty?
Indeed it is, when output is a new array.
Then how can I approach this to work for both cases:
1) output is empty?
2) output is the size of input? (MmFile's)
The code below works as is with memory mapped files' casted
opSlice's.
However, I can't figure out how to test it with simple arrays.
Its unittest fails.
Question:
How to implement the function correctly?
Otherwise what is the correct way to test it?
Thank you.
Code:
Range2 c
Why doesn't the below code compile?
How to rewrite it so that it does?
Using: DMD64 D Compiler v2.060.
Thank you.
Code:
import std.algorithm, std.ascii, std.stdio;
void main()
{
char[] rot13 = lowercase.dup;
bringToFront(rot13[0 .. 13], rot13[13 .. $]);
write