Skip to content

Commit d81d540

Browse files
committed
Merge pull request dlang#1844 from monarchdodra/fix11884
Fix issue 11884 - std.container.Array lacks a constructor from an input ...
2 parents 84dbc99 + 3409e5b commit d81d540

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

std/container.d

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,9 @@ if (!is(Unqual!T == bool))
26462646
private alias RefCounted!(Payload, RefCountedAutoInitialize.no) Data;
26472647
private Data _data;
26482648

2649+
/**
2650+
Constructor taking a number of items
2651+
*/
26492652
this(U)(U[] values...) if (isImplicitlyConvertible!(U, T))
26502653
{
26512654
auto p = cast(T*) malloc(T.sizeof * values.length);
@@ -2661,6 +2664,16 @@ if (!is(Unqual!T == bool))
26612664
_data = Data(p[0 .. values.length]);
26622665
}
26632666

2667+
/**
2668+
Constructor taking an input range
2669+
*/
2670+
this(Stuff)(Stuff stuff)
2671+
if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T) && !is(Stuff == T[]))
2672+
{
2673+
insertBack(stuff);
2674+
}
2675+
2676+
26642677
/**
26652678
Comparison for equality.
26662679
*/
@@ -3692,6 +3705,11 @@ unittest //11459
36923705
alias B = Array!(shared bool);
36933706
}
36943707

3708+
unittest //11884
3709+
{
3710+
auto a = Array!int([1, 2, 2].filter!"true"());
3711+
}
3712+
36953713
// BinaryHeap
36963714
/**
36973715
Implements a $(WEB en.wikipedia.org/wiki/Binary_heap, binary heap)

0 commit comments

Comments
 (0)