D-Programming-Language/phobos — pull request #1447 by monarchdodra (2013-08-01 15:07:22+00:00)
Title: Rewrite [Un|Minimally]InitializedArray

A rewrite.

This fixes:
http://d.puremagic.com/issues/show_bug.cgi?id=9803
http://d.puremagic.com/issues/show_bug.cgi?id=10636

This rewrite makes it so that:
* Template is only instantiated with size_t.
* * Avoids making redundant `arrayAllocImpl!int`/`arrayAllocImpl!size_t`
* More and more verbose template validations (for example, passing a `ulong` on `X86`).
* Allowed providing 0 dimensions, in which case the function returns an empty slice (why not?).
* Added safety for isPOD* types. Always nothrow.
* Memory is initialized to `0` now, and not `T.init`.
* * Probably faster
* * Doing a `ret[] = T.init` was wrong anyways.

Finally (and most important), all allocation are done using standard GC functions. This means the returned slices all have appendable data and capacity information. This is the same behaviour we'd get out of a new T[]. This is explicitly documented.

Note: @9rnsr disagreed with me about the safety only for POD, that safety should *only* be about having indirection. Until we get this sorted out, I think it would be safer to side on caution, and simply not provide safety too fast.