Shared, ref, arrays, and reserve template instantiation

James Blachly james.blachly at gmail.com
Thu Sep 13 03:42:19 UTC 2018


Great -- Thank you both.

I previously found Unqual, but it looks like that needs template 
support so wasn't feasible, hence my question.

Neia is right that I tried to cast as in the second case ( but 
without UFCS -- reserve( cast(int[]), N); ).  As an aside, what 
is going on behind the scenes with the compiler when casting away 
a property? I did not think cast operations copied data, so was 
surprised that a cast value is not an lvalue.

Regarding Jonathan's comments, we had definitely protected the ~= 
operations with Mutex, but realized we were doing lots of array 
appends in a hot loop, and since we have an idea of cardinality 
ahead of time just wanted to preallocate.  Since it is all 
initialization before concurrent code enters the picture, we'll 
do what you've suggested and set it up as TL and then cast to 
shared.

James


More information about the Digitalmars-d-learn mailing list