www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13857] New: std.algorithm.group doesn't work with range of

https://issues.dlang.org/show_bug.cgi?id=13857

          Issue ID: 13857
           Summary: std.algorithm.group doesn't work with range of
                    immutables
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx

Code:
------
import std.algorithm;
void main() {
    immutable(int)[] data = [1,1,2,2,2,3,4,4,5,6,6,7,8,9,9,9];
    auto g = group(data);
}
------

Compiler output:
------
/usr/src/d/phobos/std/algorithm.d(4475): Error: cannot modify struct
this._current Tuple!(immutable(int), uint) with immutable members
test.d(4): Error: template instance std.algorithm.group!("a == b",
immutable(int)[]) error instantiating
/usr/src/d/phobos/std/algorithm.d(4507): Error: cannot modify struct
ret._current Tuple!(immutable(int), uint) with immutable members
/usr/src/d/phobos/std/algorithm.d(4514): Error: template instance
std.algorithm.Group!("a == b", immutable(int)[]) error instantiating
test.d(4):        instantiated from here: group!("a == b", immutable(int)[])
------

Since the range itself isn't immutable, this code should work.

--
Dec 11 2014