cannot sort an array of char

Ivan Kazmenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 11 03:01:47 PST 2014


IK>> For example, isRandomAccessRange[0] states the problem:
IK>> -----
IK>> Although char[] and wchar[] (as well as their qualified
IK>> versions including string and wstring) are arrays,
IK>> isRandomAccessRange yields false for them because they use
IK>> variable-length encodings (UTF-8 and UTF-16 respectively).
IK>> These types are bidirectional ranges only.
IK>> -----
IK>> but does not offer a solution.  If (when) byCodeUnit does
IK>> really provide a random-access range, it would be desirable 
to
IK>> have it linked where the problem is stated.
IK>>
IK>> [0] 
http://dlang.org/phobos/std_range.html#.isRandomAccessRange

MS> I agree. But how should it be implemented? We would have to
MS> modify algorithms that require an RA range to also accept
MS> char[], but then print an error message with the suggestion to
MS> use byCodeUnit. I think that's not practicable. Any better
MS> ideas?

I meant just mentioning a workaround (byCodeUnit or 
representation) in the documentation, not in a compiler error.  
But the latter option does have some sense, too.


More information about the Digitalmars-d-learn mailing list