Skip to content

Commit

Permalink
Only define Until.save() forward ranges
Browse files Browse the repository at this point in the history
std.algorithm.Until.save() was defined for all ranges, but should only
be defined when the underlying range is a forward range.
  • Loading branch information
kyllingstad committed May 16, 2011
1 parent 3b628ae commit dc352ea
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions std/algorithm.d
Expand Up @@ -3655,29 +3655,32 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
}
}

static if (!is(Sentinel == void))
@property Until save()
{
Until result;
static if (isForwardRange!Range)
{
static if (!is(Sentinel == void))
@property Until save()
{
Until result;

result._input = _input.save;
result._sentinel = _sentinel;
result._openRight = _openRight;
result._done = _done;
result._input = _input.save;
result._sentinel = _sentinel;
result._openRight = _openRight;
result._done = _done;

return result;
}
else
@property Until save()
{
Until result;
return result;
}
else
@property Until save()
{
Until result;

result._input = _input.save;
result._openRight = _openRight;
result._done = _done;
result._input = _input.save;
result._openRight = _openRight;
result._done = _done;

return result;
}
return result;
}
}
}

/// Ditto
Expand Down

0 comments on commit dc352ea

Please sign in to comment.