On Monday, 22 September 2014 at 00:09:22 UTC, Vladimir Panteleev wrote:
On Sunday, 21 September 2014 at 23:48:59 UTC, AsmMan wrote:
On Sunday, 21 September 2014 at 23:41:58 UTC, AsmMan wrote:
I'd like to copy an array string into a appender!string() but I can't see how to do this without loop myself over the string array. Is there a native function or should I write it myself?

call:

auto app = appender!string();
        string[] s = ["foo", "baa"];
        app.put(s);

give a:

\src\phobos\std\conv.d(9,9): Error: static assert "immutable(char) cannot be emplaced from a string." (b)

How do I fix it?

put(app, s);

This is not an ideal solution, since Appender may reallocate several times when appending the array items. Ideally, appender itself should take a range of strings, so that it can preallocate memory for them only once.

this give undefined identifier: 'put' error. (std.array is already included, buffer.put(string) doesn't give same error)

The copy of an array doesn't happen often as string but do suggest to I want something else instead of appender?

Reply via email to