Skip to content

Commit

Permalink
Issue 13689: byCodeUnit fails to be a random access range.
Browse files Browse the repository at this point in the history
Add static assert to ensure random accessability.
  • Loading branch information
H. S. Teoh committed Nov 5, 2014
1 parent 3bb4bb2 commit 8898fe5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion std/utf.d
Expand Up @@ -2719,7 +2719,7 @@ auto byCodeUnit(R)(R r) if (isNarrowString!R)
void popFront() { r = r[1 .. $]; }
auto ref opIndex(size_t index) inout { return r[index]; }

@property auto ref back() const
@property auto ref back() inout
{
return r[$ - 1];
}
Expand Down Expand Up @@ -2749,6 +2749,8 @@ auto byCodeUnit(R)(R r) if (isNarrowString!R)
R r;
}

static assert(isRandomAccessRange!ByCodeUnitImpl);

return ByCodeUnitImpl(r);
}

Expand Down

0 comments on commit 8898fe5

Please sign in to comment.