D-Programming-Language/phobos — pull request #756 by jmdavis (2012-08-22 09:03:20+00:00)
Title: Move std.container.make to std.typecons and expand on it

This pull request does the following:

1. Move `std.container.make` to `std.typecons` and makes it work with all types rather than just classes and structs (while aliasing and scheduling for deprecation `std.container.make`).

2. Add `std.typecons.makeNew` which is the same as `make` except that it always uses `new`.

3. Add `std.typecons.makeArray`, which is a specialized version of `make` for arrays with the idea that it makes it so that you can construct arrays of integral types smaller than `int` without all of the casting that you have to do with integer literals (`makeArray` does the casting for you).

4. Add `std.typecons.makeStaticArray`, which is the same as `makeArray` except that it's for static arrays. It also has the benefit of inferring the length of the array. Both it and `make` also avoid heap allocations when initializing static arrays.

These functions should make generic type construction easier in the cases where generic type construction makes sense as well as clean up constructing arrays with integer literals. I would think that `makeNew` (and possibly `makeArray`) would be the same as what custom allocators would have for constructing types (though presumably custom allocators would use the name `make` or `alloc` rather than `makeNew`), but I guess that that would depend on the exact design of custom allocators, which hasn't been finalized yet. However, these functions should be useful regardless of what happens with custom allocators, and they're an extension of what we already have with `std.container.make`.