D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13689 - byCodeUnit fails to be a random access range
Summary: byCodeUnit fails to be a random access range
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2014-11-05 13:44 UTC by Marc Schütz
Modified: 2015-02-18 03:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Marc Schütz 2014-11-05 13:44:04 UTC
This doesn't compile with Phobos master:

import std.algorithm;
import std.utf;
void main () {
    char [] c;
    sort (c.byCodeUnit);
}

For whatever reasons, it doesn't satisfy `isRandomAccessRange`.
Comment 1 bearophile_hugs 2014-11-05 14:21:21 UTC
This works:

void main() {
    import std.algorithm: sort;
    import std.string: representation;
    char[] arr = "ACBA".dup;
    arr.representation.sort();
    assert(arr == "AABC");
}
Comment 3 github-bugzilla 2014-11-10 20:23:02 UTC
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/8898fe5571885a2cd88a940743969f53a0f67925
Issue 13689: byCodeUnit fails to be a random access range.

Add static assert to ensure random accessability.

https://github.com/D-Programming-Language/phobos/commit/77b4b8ac22d2cb505dcb11fcbcb1e42f35c5881a
Merge pull request #2656 from quickfur/issue13689

[trivial] Issue 13689: byCodeUnit fails to be a random access range.
Comment 4 hsteoh 2014-11-10 20:36:54 UTC
Confirmed fixed on git HEAD. Tested on Linux/64.