From 8898fe5571885a2cd88a940743969f53a0f67925 Mon Sep 17 00:00:00 2001 From: "H. S. Teoh" Date: Wed, 5 Nov 2014 06:51:14 -0800 Subject: [PATCH] Issue 13689: byCodeUnit fails to be a random access range. Add static assert to ensure random accessability. --- std/utf.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/std/utf.d b/std/utf.d index e6081403fdf..62faf8e013a 100644 --- a/std/utf.d +++ b/std/utf.d @@ -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]; } @@ -2749,6 +2749,8 @@ auto byCodeUnit(R)(R r) if (isNarrowString!R) R r; } + static assert(isRandomAccessRange!ByCodeUnitImpl); + return ByCodeUnitImpl(r); }