mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 15:40:36 +03:00
Improve Issue 10220 fix.
Improves pull #1329. Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=10220
This commit is contained in:
parent
7b0a1219fd
commit
51a5bad3e6
1 changed files with 11 additions and 4 deletions
15
std/array.d
15
std/array.d
|
@ -343,10 +343,17 @@ if(allSatisfy!(isIntegral, I))
|
||||||
|
|
||||||
auto ptr = (__ctfe) ?
|
auto ptr = (__ctfe) ?
|
||||||
{
|
{
|
||||||
E[] arr;
|
static if(__traits(compiles, new E[1]))
|
||||||
foreach (i; 0 .. sizes[0])
|
{
|
||||||
arr ~= E.init;
|
return (new E[sizes[0]]).ptr;
|
||||||
return arr.ptr;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
E[] arr;
|
||||||
|
foreach (i; 0 .. sizes[0])
|
||||||
|
arr ~= E.init;
|
||||||
|
return arr.ptr;
|
||||||
|
}
|
||||||
}() :
|
}() :
|
||||||
cast(E*) GC.malloc(sizes[0] * E.sizeof, blockAttribute!(E));
|
cast(E*) GC.malloc(sizes[0] * E.sizeof, blockAttribute!(E));
|
||||||
auto ret = ptr[0..sizes[0]];
|
auto ret = ptr[0..sizes[0]];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue