Skip to content

Commit

Permalink
Remove forwarding of save and remove unittests for save functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MetaLang committed Mar 18, 2014
1 parent d882fb4 commit 8eabb58
Showing 1 changed file with 0 additions and 68 deletions.
68 changes: 0 additions & 68 deletions std/range.d
Expand Up @@ -9823,14 +9823,6 @@ auto tee(alias fun, Flag!"pipeOnPop" pipeOnPop = Yes.pipeOnPop, Range)(Range inp
{
return _input.length;
}

static if (isRandomAccessRange!Range)
{
private alias IndexType = CommonType!(size_t, typeof(_input.length));
auto ref opIndex(IndexType n) { return _input[n]; }

alias opDollar = length;
}
}

static if (isInfinite!Range)
Expand Down Expand Up @@ -9860,36 +9852,6 @@ auto tee(alias fun, Flag!"pipeOnPop" pipeOnPop = Yes.pipeOnPop, Range)(Range inp
}
return _input.front;
}

static if (isBidirectionalRange!Range)
{
void popBack()
{
assert(!_input.empty);
static if (pipeOnPop)
{
_fun(_input.back);
}
_input.popBack();
}

@property auto ref back()
{
static if (!pipeOnPop)
{
_fun(_input.front);
}
return _fun(_input.back);
}
}

static if (isForwardRange!Range)
{
@property auto save()
{
return typeof(this)(_input.save);
}
}
}

return Result(inputRange);
Expand Down Expand Up @@ -9968,33 +9930,3 @@ unittest
testRange(pipeOnFront);
assert(frontCount == 9);
}

unittest
{
// Verify save behavior, using a reference type InputRange.
class C
{
int _data;
@property int front() { return _data; }
@property bool empty() { return false; }
void popFront() { _data++; }
@property auto save()
{
C result = new C();
result._data = _data;
return result;
}
}

C nums = new C();

auto range = nums.tee!(a => a + 1);
range.popFront();
assert(range.front == 1);

auto saved = range.save;
range.popFront();
range.popFront();
assert(range.front == 3);
assert(saved.front == 1);
}

0 comments on commit 8eabb58

Please sign in to comment.