On Thursday, 27 April 2017 at 18:36:08 UTC, Alex wrote:
* I'm pretty sure that the code is going to be invalid when
you're dealing with const/immutable data.
Ok... this is important... I tried this out, and the value of
the immutable data even remains the same. But for safety
reasons, I would reconstruct the structs inside the array
anyway, so I can live with this, I think...
move() is only destructive if the type has custom postblit or
destructor, otherwise it's just a bitwise copy. But, as
mentioned, there's an issue with it at the moment: it doesn't
really care if the type being moved has const/immutable members.
uninitializedArray is scary. If you do use it, probably best to
localize the usage as much as possible and be very very VERY
careful with it ;)
Here's a sketch of something that's a little bit more convenient:
https://dpaste.dzfl.pl/ee472fd872a5
But I'm not going to pretend it'd survive a review.
Also note that, going back to your original question, docs for
scoped state that it's illegal to move it, so that particular
type you can't really store in any of these arrays.