Skip to content

Commit

Permalink
Fix DList.insertFront(range) regression - #15263.
Browse files Browse the repository at this point in the history
As createNode was taking a value by ref, Dlist.insertFront could not be
called with a range with a non-ref front.

Fix by taking the value as `auto ref` instead of just `ref`.
Resolves #15263.
  • Loading branch information
rcorre committed Oct 31, 2015
1 parent 168d96d commit 05fd49e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion std/container/dlist.d
Expand Up @@ -163,7 +163,7 @@ struct DList(T)
private
{
//Construct as new PayNode, and returns it as a BaseNode.
static BaseNode* createNode(Stuff)(ref Stuff arg, BaseNode* prev = null, BaseNode* next = null)
static BaseNode* createNode(Stuff)(auto ref Stuff arg, BaseNode* prev = null, BaseNode* next = null)
{
return (new PayNode(BaseNode(prev, next), arg)).asBaseNode();
}
Expand Down Expand Up @@ -936,3 +936,11 @@ private:

DList!ITest().insertBack(new Test());
}

@safe unittest //15263
{
import std.range : iota;
auto a = DList!int();
a.insertFront(iota(0, 5)); // can insert range with non-ref front
assert(a.front == 0 && a.back == 4);
}

0 comments on commit 05fd49e

Please sign in to comment.