Skip to content

Commit

Permalink
Merge pull request #5264 from s-ludwig/master
Browse files Browse the repository at this point in the history
Fix issue 17251 - Appender.put doesn't accept const input range elements
merged-on-behalf-of: H. S. Teoh <quickfur@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Mar 29, 2017
2 parents be8f1dd + bdb626f commit 23726d6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion std/array.d
Expand Up @@ -2880,7 +2880,8 @@ if (isDynamicArray!A)
{
enum bool canPutConstRange =
isInputRange!(Unqual!Range) &&
!isInputRange!Range;
!isInputRange!Range &&
is(typeof(Appender.init.put(Range.init.front)));
}
private template canPutRange(Range)
{
Expand Down Expand Up @@ -3072,6 +3073,21 @@ if (isDynamicArray!A)
assert("%s".format(app) == "Appender!(int[])(%s)".format([1,2,3]));
}

@safe unittest // issue 17251
{
static struct R
{
int front() const { return 0; }
bool empty() const { return true; }
void popFront() {}
}

auto app = appender!(R[]);
const(R)[1] r;
app.put(r[0]);
app.put(r[]);
}

//Calculates an efficient growth scheme based on the old capacity
//of data, and the minimum requested capacity.
//arg curLen: The current length
Expand Down

0 comments on commit 23726d6

Please sign in to comment.