Re: std.base64 question

2013-11-26 Thread Adam D. Ruppe
On Wednesday, 27 November 2013 at 03:14:38 UTC, Parke wrote: Are slices passed (and returned) by value or by reference? By value, though they are a pointer into the data. void foo(int[] data) { data[0] = 20; data ~= 100; } void main() { int[4] buffer; foo(buffer[]); // slice passed by

Re: std.base64 question

2013-11-26 Thread Parke
On Wednesday, 27 November 2013 at 02:49:19 UTC, Adam D. Ruppe wrote: The slice operator, [], returns a view into the array that can be advanced by the encode function as needed. Thanks. Are slices passed (and returned) by value or by reference?

Re: std.base64 question

2013-11-26 Thread Jesse Phillips
On Wednesday, 27 November 2013 at 02:43:56 UTC, Parke wrote: The compile error is: [snip]/src/phobos/std/range.d(614): Error: static assert "Cannot put a immutable(char) into a char[40]" [snip]/src/phobos/std/base64.d(297):instantiated from here: put!(char[40], immutable(char)) test.d

Re: std.base64 question

2013-11-26 Thread Adam D. Ruppe
On Wednesday, 27 November 2013 at 02:43:56 UTC, Parke wrote: [snip]/src/phobos/std/range.d(614): Error: static assert "Cannot put a immutable(char) into a char[40]" Static arrays aren't considered ranges in templates because their length can't change. If you slice it, however, it will work,

std.base64 question

2013-11-26 Thread Parke
Hi, The following does not compile, and I do not understand what I am doing wrong. import std.base64; ubyte[] s0 = ['H','e','l','l','o']; char[40] s1; void main () { Base64.encode (s0, s1); } The compile error is: [snip]/src/phobos/std/range.d(614): Error: static assert "Cannot put a im