Re: ubyte[] -> immutable(ubyte)[]

2016-05-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/3/16 5:31 PM, vino wrote: On Friday, 10 September 2010 at 15:15:38 UTC, Andrej Mitrovic wrote: Yeah, one would think the destination is on the left (just like the standard C way of doing it), but it's not. I checked it in the docs and the source. And idup works, thanks. Kagamin Wrote: An

Re: ubyte[] -> immutable(ubyte)[]

2016-05-03 Thread vino via Digitalmars-d-learn
On Friday, 10 September 2010 at 15:15:38 UTC, Andrej Mitrovic wrote: Yeah, one would think the destination is on the left (just like the standard C way of doing it), but it's not. I checked it in the docs and the source. And idup works, thanks. Kagamin Wrote: Andrej Mitrovic Wrote: > fo

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Andrej Mitrovic
Yeah, one would think the destination is on the left (just like the standard C way of doing it), but it's not. I checked it in the docs and the source. And idup works, thanks. Kagamin Wrote: > Andrej Mitrovic Wrote: > > > foreach (ubyte[] buffer; stdin.byChunk(bufferSize)) > > { > >

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Andrej Mitrovic
Ah, idup. Too obvious, but I missed it. Thanks. Pelle Wrote: > std.algorithm.copy will copy an input range into an output range. An > array is a valid output range, but does not append as you seem to > expect. Instead, it fills the array. > > int[] a = new int[](3); > copy([1,2,3],a); > assert

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Andrej Mitrovic
bearophile Wrote: > Andrej Mitrovic: > > I'm trying to use algorithm.copy, but I get back nothing in the copy > > buffer. How do I to copy an array of ubyte's? > > a[] = b[]; > > Bye, > bearophile No, that wouldn't work. It complains about conversion from mutable to immutable. idup works fin

Re: ubyte[] -> immutable(ubyte)[]

2010-09-10 Thread Pelle
On 09/10/2010 04:40 AM, Andrej Mitrovic wrote: I'm trying to use algorithm.copy, but I get back nothing in the copy buffer. How do I to copy an array of ubyte's? iimport std.algorithm, std.concurrency, std.stdio; void main() { enum bufferSize = 4; auto tid = spawn(&

Re: ubyte[] -> immutable(ubyte)[]

2010-09-09 Thread Kagamin
Andrej Mitrovic Wrote: > foreach (ubyte[] buffer; stdin.byChunk(bufferSize)) > { > immutable(ubyte)[] copy_buffer; > copy(buffer, copy_buffer); > > writeln(copy_buffer); // writes nothing > > send(tid, copy_buffer); > } Isn't destination the

Re: ubyte[] -> immutable(ubyte)[]

2010-09-09 Thread bearophile
Andrej Mitrovic: > I'm trying to use algorithm.copy, but I get back nothing in the copy buffer. > How do I to copy an array of ubyte's? a[] = b[]; Bye, bearophile

Re: ubyte[] -> immutable(ubyte)[]

2010-09-09 Thread Andrej Mitrovic
I'm trying to use algorithm.copy, but I get back nothing in the copy buffer. How do I to copy an array of ubyte's? iimport std.algorithm, std.concurrency, std.stdio; void main() { enum bufferSize = 4; auto tid = spawn(&fileWriter); // Read loop foreach (ubyte[

ubyte[] -> immutable(ubyte)[]

2010-09-03 Thread Andrej Mitrovic
This is from TDPL page 407: import std.algorithm, std.concurrency, std.stdio; void main() { enum bufferSize = 1024 * 100; auto tid = spawn(&fileWriter); // Read loop foreach (immutable(ubyte)[] buffer; stdin.byChunk(bufferSize)) { send(tid, buffer);