Skip to content

Commit

Permalink
Add index < length assert to iota.opIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
brad-anderson committed Apr 21, 2012
1 parent 028699f commit 23bfcd7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions std/range.d
Original file line number Diff line number Diff line change
Expand Up @@ -4361,6 +4361,8 @@ if ((isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))
@property auto save() { return this; }
Value opIndex(ulong n)
{
assert(n < this.length);

// Just cast to Value here because doing so gives overflow behavior
// consistent with calling popFront() n times.
return cast(Value) (current + step * n);
Expand Down Expand Up @@ -4427,6 +4429,8 @@ if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))
@property auto save() { return this; }
Value opIndex(ulong n)
{
assert(n < this.length);

// Just cast to Value here because doing so gives overflow behavior
// consistent with calling popFront() n times.
return cast(Value) (current + n);
Expand Down

0 comments on commit 23bfcd7

Please sign in to comment.