http://d.puremagic.com/issues/show_bug.cgi?id=5924
Summary: schwartzSort of Tuple!(char)[] Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2011-05-03 04:41:04 PDT --- D2 code: import std.algorithm, std.typecons; void main() { //Tuple!(int)[] chars; // OK Tuple!(char)[] chars; // Error schwartzSort!((c){ return c[0]; })(chars); } It doesn't compile with DMD 2.052: ...\dmd\src\phobos\std\algorithm.d(5911): Error: template instance SortedRange!(Zip!(char[],Tuple!(char)[]),myLess) does not match template declaration SortedRange(Range,alias pred = "a < b") if (isRandomAccessRange!(Range)) ...\dmd\src\phobos\std\algorithm.d(5912): Error: SortedRange!(Zip!(char[],Tuple!(char)[]),myLess) is used as a type You can't sort efficiently the items of an Unicode string because in general they don't have the same length. But a dynamic array of Tuple!(char) is composed by items 1 byte long, and generally it's not meant to be a string. So in this case I expect schwartzSort to be able to sort it. Current workaround: import std.algorithm, std.typecons; void main() { Tuple!(char)[] chars; schwartzSort!((c){ return cast(int)c[0]; })(chars); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------