Output range with custom string type

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 31 00:06:26 PDT 2017


On 2017-08-29 19:35, Moritz Maxeiner wrote:

>      void put(T t)
>      {
>          if (!store)
>          {
>              // Allocate only once for "small" vectors
>              store = alloc.makeArray!T(8);
>              if (!store) onOutOfMemoryError();
>          }
>          else if (length == store.length)
>          {
>              // Growth factor of 1.5
>              auto expanded = alloc.expandArray!char(store, store.length 
> / 2);
>              if (!expanded) onOutOfMemoryError();
>          }
>          assert (length < store.length);
>          moveEmplace(t, store[length++]);
>      }

What's the reason to use "moveEmplace" instead of just assigning to the 
array: "store[length++] = t" ?

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list