On Tue, 06 May 2014 15:32:23 -0400, Dmitry Olshansky
<[email protected]> wrote:
06-May-2014 04:10, Andrei Alexandrescu пишет:
So I'm looking at creation functions and in particular creation
functions for arrays.
1. Follow the new int[n] convention:
auto a = allok.make!(int[])(42);
assert(a.length == 42);
assert(a.equal(repeat(0, 42));
Have this primitive to keep it simple.
(i.e. make => pass args to "ctor")
Especially in the case of int[][][] and such.
I agree with the spirit of your idea, but not the implementation.
make!T(args) should build an instance of that type on the heap, and then
call it's constructor.
In the case of T == int[], it should mean put an int[] on the heap, not
allocate a block, and give me an int[] reference to it.
Array is a special case IMO, and deserves its own primitive.
-Steve