Timon Gehr Wrote:

> On 09/08/2011 03:07 PM, Jason House wrote:
> > bearophile Wrote:
> >
> >> With the latest DMD versions it's easy to create an immutable array of 
> >> structs, with a pure function (I think this gives advantages similar to 
> >> the Transients of the Clojure language):
> >>
> >>
> >> ...
> >
> > Two alternate ideas:
> > 1. Reserve the required space then start appending
> 
> This is still pretty slow at the moment because afaik each append is a 
> runtime call.

If you do it a bit more manually, you can use emplace.


> > 2. Use a const-free struct to build the array and then cast array to the 
> > proper type on return.
> 
> That is a nice idea, it could be implemented using a constFree!Struct 
> template struct.

Thanks. A constFree template is likely very useful. I wonder how frequently it 
would get abused. 

Reply via email to