Skip to content

Commit

Permalink
Merge pull request #5473 from dmarquant/bug12866
Browse files Browse the repository at this point in the history
Issue 12866: Allows concatenating of std.container.array with static arrays as T.
merged-on-behalf-of: Petar Kirov <[email protected]>
  • Loading branch information
dlang-bot authored Jun 26, 2017
2 parents 47aa7b9 + 4de14ab commit 8f98afc
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions std/container/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,10 @@ if (!is(Unqual!T == bool))
/**
* Forwards to `insertBack`.
*/
void opOpAssign(string op, Stuff)(Stuff stuff)
void opOpAssign(string op, Stuff)(auto ref Stuff stuff)
if (op == "~")
{
static if (is(typeof(stuff[])))
static if (is(typeof(stuff[])) && isImplicitlyConvertible!(typeof(stuff[0]), T))
{
insertBack(stuff[]);
}
Expand Down Expand Up @@ -2400,3 +2400,20 @@ if (is(Unqual!T == bool))
assert(a.length == 11, to!string(a.length));
assert(a[5]);
}
@system unittest
{
alias V3 = int[3];
V3 v = [1, 2, 3];
Array!V3 arr;
arr ~= v;
assert(arr[0] == [1, 2, 3]);
}
@system unittest
{
alias V3 = int[3];
V3[2] v = [[1, 2, 3], [4, 5, 6]];
Array!V3 arr;
arr ~= v;
assert(arr[0] == [1, 2, 3]);
assert(arr[1] == [4, 5, 6]);
}

0 comments on commit 8f98afc

Please sign in to comment.