Question about OutputRange and std.range: put
Uranuz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 16 08:53:24 PST 2016
On Saturday, 16 January 2016 at 16:14:56 UTC, Jonathan M Davis
wrote:
> On Saturday, January 16, 2016 12:11:11 Uranuz via
> Digitalmars-d-learn wrote:
>> [...]
>
> There are a few problems here. First off, when put is used with
> an array, it fills the array. It doesn't append to it. So, you
> can't use a string as an output range, since its elements are
> immutable. Here's an example with int[]:
>
> [...]
Thanks for your response. After looking for some time in Phobos
documentation I already found that it would be better to use
Appender for this purpose. As far as I understand it allocates
less often and I can reserve some memory from the start. I'll
take this possibility into account when I'll do further small
optimisations. Thanks again.
More information about the Digitalmars-d-learn
mailing list