From 43a77fa50c983ff55c54d455da5a7c94b88638c5 Mon Sep 17 00:00:00 2001 From: monarch dodra Date: Thu, 24 Oct 2013 12:37:41 +0200 Subject: [PATCH] support for empty static arrays in ElementEncodingType --- std/range.d | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/std/range.d b/std/range.d index 23aa640a1..e98a7bd1b 100644 --- a/std/range.d +++ b/std/range.d @@ -1044,6 +1044,14 @@ unittest static assert(is(ElementType!(inout(int)[]) : inout(int))); } +unittest +{ + static assert(is(ElementType!(int[5]) == int)); + static assert(is(ElementType!(int[0]) == int)); + static assert(is(ElementType!(char[5]) == dchar)); + static assert(is(ElementType!(char[0]) == dchar)); +} + unittest //11336 { static struct S @@ -1063,7 +1071,7 @@ $(D ElementType). template ElementEncodingType(R) { static if (isNarrowString!R) - alias typeof(lvalueOf!R[0]) ElementEncodingType; + alias typeof(*lvalueOf!R.ptr) ElementEncodingType; else alias ElementType!R ElementEncodingType; } @@ -1086,6 +1094,14 @@ unittest static assert(is(ElementEncodingType!(inout char[]) : inout(char))); } +unittest +{ + static assert(is(ElementEncodingType!(int[5]) == int)); + static assert(is(ElementEncodingType!(int[0]) == int)); + static assert(is(ElementEncodingType!(char[5]) == char)); + static assert(is(ElementEncodingType!(char[0]) == char)); +} + /** Returns $(D true) if $(D R) is a forward range and has swappable elements. The following code should compile for any range