Skip to content

Commit

Permalink
Merge pull request #1832 from monarchdodra/takeBack
Browse files Browse the repository at this point in the history
Fix Take's "back"
  • Loading branch information
AndrejMitrovic committed Jan 5, 2014
2 parents 09ae8ff + e151ccf commit 351903b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion std/range.d
Expand Up @@ -3194,7 +3194,7 @@ if (isInputRange!(Unqual!Range) &&

static if (hasAssignableElements!R)
{
auto back(ElementType!R v)
@property auto back(ElementType!R v)
{
// This has to return auto instead of void because of Bug 4706.
assert(!empty,
Expand Down Expand Up @@ -3347,6 +3347,16 @@ unittest
t3 = take(t2, 1);
}

unittest
{
alias R1 = typeof(repeat(1));
alias R2 = typeof(cycle([1]));
alias TR1 = Take!R1;
alias TR2 = Take!R2;
static assert(isBidirectionalRange!TR1);
static assert(isBidirectionalRange!TR2);
}

/**
Similar to $(LREF take), but assumes that $(D range) has at least $(D
n) elements. Consequently, the result of $(D takeExactly(range, n))
Expand Down

0 comments on commit 351903b

Please sign in to comment.