http://d.puremagic.com/issues/show_bug.cgi?id=6256
Summary: [patch] std.algorithm.map does not support static arrays and has 'length' for narrow strings. Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: patch Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: sandf...@jhu.edu --- Comment #0 from Rob Jacques <sandf...@jhu.edu> 2011-07-05 17:12:18 PDT --- std.algorithm.map doesn't support static arrays. Two minor changes to map, and one to std.functional.unaryFunImpl (listed below) were required to make this work. - auto map(Range)(Range r) if (isInputRange!(Unqual!Range)) + auto map(Range)(auto ref Range r) + if (isInputRange!(Unqual!Range) || isArray!Range ) - alias Unqual!Range R; + static if(is(Unqual!Range E:E[]) ) { + alias E[] R; + } else { + alias Unqual!Range R; + } also, map adds a length member for narrow strings. This can be fixed by changing the appropriate static if statement. - static if (hasLength!R || isSomeString!R) + static if (hasLength!R) Also, I found that a patch to unaryFunImpl similar to the patch in Issue 5406 for binaryFunImpl was needed to compile a simple test case: void main(string[] args) { uint[5] testing = [1,2,3,4,5]; writeln( map!"a"("testing") ); return; } correctly. That patch is below: template unaryFunImpl(alias fun, bool byRef, string parmName = "a") { static if (is(typeof(fun) : string)) { enum testAsExp = "{ ElementType "~parmName ~"; return ("~fun~"); }()"; static if (byRef) { typeof(mixin(testAsExp)) result(ElementType)(ref ElementType __a) if(__traits(compiles, mixin(testAsExp))) { mixin("alias __a "~parmName~";"); mixin("return (" ~ fun ~ ");"); } } else { typeof(mixin(testAsExp)) result(ElementType)(ElementType __a) if(__traits(compiles, mixin(testAsExp))) { mixin("alias __a "~parmName~";"); mixin("return (" ~ fun ~ ");"); } } } else { alias fun result; } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------